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?

4
  • 1
    Did you searched on google before asking this? Commented Feb 16, 2016 at 8:56
  • Found it! I found my answer on this post stackoverflow.com/questions/1199352/…. Commented Feb 16, 2016 at 8:59
  • 1
    No @JohnRoca , this task is better to make in css, not javascript!. stackoverflow.com/questions/17779293/… Commented Feb 16, 2016 at 9:00
  • @mixin ellipsisMe { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .selector { @include ellipsisMe; } Commented Feb 16, 2016 at 13:56

1 Answer 1

-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.

Sign up to request clarification or add additional context in comments.

5 Comments

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)
@Tahir Thank you for your answer. But I was looking for a CSS Solution.
@MarcosPérezGude I agree with your idea that CSS is better to use rather than using JS for adding ellipses on a truncated String.
For using css approach you cannot count characters
@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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.