5

Is it possible to trim the ending of the text?

INPUT

this is an extremely very long text

RESULT

this is an ...

Boaz
  • 19,892
  • 8
  • 62
  • 70
001
  • 62,807
  • 94
  • 230
  • 350

2 Answers2

12

Yes, that is possible to achieve solely by CSS.

See my Example on jsFiddle

Key for achieving the effect is to use a combination of the following CSS-properties:

width: [x]px
overflow: hidden
white-space: nowrap
text-overflow: ellipsis

The width is neccessary to use overflow. Overflow is needed for text-overflow and white-space is needed to prevent breaks and to assure that the whole text is in one line.

hurrtz
  • 1,871
  • 1
  • 19
  • 34
9

Maybe you can try

text-overflow:ellipsis;

http://davidwalsh.name/css-ellipsis

ChoiZ
  • 747
  • 1
  • 5
  • 23