Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim Text with "..." if it is too long

Tags:

css

I have a div of certain size. Now whenever data is coming to that div from database, the excess length of the text is coming down as wrap text (like MS Excel). I want it to be in one line and obviously within the div. End the line with "..."

Can anyone help me to do so using css.

Thanks in advance

like image 591
Monibrata Avatar asked Dec 28 '25 17:12

Monibrata


1 Answers

You can use this:

text-overflow: ellipsis;

It will render '...' if it is too long.

Reference: http://www.w3schools.com/cssref/css3_pr_text-overflow.asp

Edit: Thanks to AndyM's comment, you can also use white-space:nowrap to handle white spaces overflow:hidden to prevent text overflow.

like image 118
sidney Avatar answered Dec 31 '25 08:12

sidney