0

this is an HTML code (css places in here) that displays only text that is inside the div. The text that is ouside the dive looks truncated which is perfect.

<div style="height:40px;overflow:hidden;width:260px; border:1px solid red;">
 a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z
</div>

The question is: is it possible to show at the end of the truncated text "..." ? So, if text is not truncated and fits that div, no ... is displayed, otherwise displayed "...".

jsFiddle preview is available here

CSS only - is it possible? Thank you.

Haradzieniec
  • 9,086
  • 31
  • 117
  • 212
  • Possible dup: http://stackoverflow.com/questions/6222616/with-css-use-for-overflowed-block-of-multi-lines – Salman A Feb 03 '15 at 13:18

1 Answers1

3

You can use CSS like below achieve the result you need.

overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap; 

Working example text-overflow

Sridhar DD
  • 1,972
  • 1
  • 10
  • 17