1

Is there some way to stop text from wrapping over more than 2 lines. If the text is short it will appear on 1 line. Longer text then goes onto the second line but I want to stop there and put ellipses at the end and not have the text go onto the 3rd or further lines.

I have seen this post but it deals with stopping the wrapping after the first line.

Community
  • 1
  • 1
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304

2 Answers2

2

DEMO

You can limit the maximum height of element and put overflow: hidden; to keep it max 2 lines.

keep your values in em so that this solution works for any font size.

Code:

p{
    font-size: 20px;
    line-height: 1.5em;
    max-height: 3.2em;
    overflow: hidden;
}
Imran Bughio
  • 4,811
  • 2
  • 30
  • 53
  • 2
    This does not put any ellipses anywhere, so it does not do what the question asks for. It may be a good answer to some other question. – Jukka K. Korpela Aug 22 '14 at 13:27
1

You can specify div height, with overflow hidden css property. It will not show the 3rd line.

If you want to put ellipses, you will need to use javascriot/JQuery solution, to limit the length of the string.

Jatinder Kumar
  • 503
  • 6
  • 17