I want to wrap a text within only two lines inside div of specific width. If text goes beyond the length of two lines then I want to show ellipses.
Is there a way to do that using CSS?
e.g.
Sample text showing wrapping
of text in only two line...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Limiting output to two lines of text is possible with CSS, if you set the
line-heightandheightof the element, and setoverflow:hidden;:— jsFiddle DEMO —
Alternatively, you can use the CSS
text-overflowandwhite-spaceproperties to add ellipses, but this only appears to work for a single line.And a demo:
— jsFiddle DEMO —
Achieving both multiple lines of text and ellipses appears to be the realm of javascript.