0

I have a text that needs to be truncated in some defined length (say 14) and I want to add an ellipses to the end of the truncated text.

Example Output:

Some text here...

Can this be done in CSS?

John Roca
  • 1,204
  • 1
  • 14
  • 27

1 Answers1

-2

Css dont know the number of characters. It only knows box model. In a project i had worked on elipses with css but it is worst idea. For a better approach use javacript.

Tahir Shahzad
  • 649
  • 7
  • 18
  • 1
    In the real world, it's exactly the opposite. Is better to use CSS for this purpose, not count the characters of an string (each character is different size / weight than others) – Marcos Pérez Gude Feb 16 '16 at 08:59
  • @Tahir Thank you for your answer. But I was looking for a CSS Solution. – John Roca Feb 16 '16 at 09:00
  • @MarcosPérezGude I agree with your idea that CSS is better to use rather than using JS for adding ellipses on a truncated String. – John Roca Feb 16 '16 at 09:01
  • 1
    For using css approach you cannot count characters – Tahir Shahzad Feb 16 '16 at 09:04
  • @TahirShahzad I was not able to count the characters Yes. But the container has its own width so I thought counting the character would suffice. Anyways. My Question was answered. Thank you for your answer. – John Roca Feb 16 '16 at 09:08