Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clip text in css like gmail does to emails subject listings

Tags:

html

css

in gmail, they display the

subject - followed by a short snippet from the body

and it looks like the body text is clipped, i am assuming this is done with css, gmail style sheets are fairly complex, so am not certain

anyway only parts of letters are showing at the end of the line where they get chopped off

does anyone know how i can achieve the same effect, so i get full length text in a column


got it sussed thanks @cletus

just to clarify, this is what i ended up with

<div style="overflow: hidden; height: 20px;">mytitle<span style="color: gray; "> - my long description goes here</span></div>
like image 606
bumperbox Avatar asked Aug 05 '09 10:08

bumperbox


2 Answers

To get the full text-clipping effect, where only parts of letters show at the end of the element, just add:

white-space: nowrap;
like image 133
stubotnik Avatar answered Oct 08 '22 16:10

stubotnik


It's overflow: hidden CSS on block elements. The block-level element part is important. See The CSS Overflow Property.

like image 26
cletus Avatar answered Oct 08 '22 15:10

cletus