View Full Version : clipping text to a certain width

11-04-2003, 10:59 PM
Is there anyway to clip text to a specified width?
What I'm looking for is a way to take long text that doesn't wrap in a table (text without spaces, like email address) and have the table clip it to show only what will fit in the cell.

I was thinking of having a DIV in the cell like so...
<TD width="30%" >
<DIV style="overflow:hidden">blah blah some long text</DIV>

This seems kinda nasty to have in all the table cells, so I'm wondering if someone has a better idea

11-04-2003, 11:18 PM
well, that didn't work... Any suggestions? I can't clip the text using jsp/java code since its the browser that determines the width of the table. Is there any fancy javascript function to clip text to a specified pixel width? See the sample bmp which illustrates the problem. The third row text does not wrap and causes the table cell to expand beyond its specified width

11-04-2003, 11:44 PM
You need to fix the format of the table:

<table style="table-layout:fixed">

Then <td style="overflow:hidden"> should do the trick, though I think when table layout is fixed that the overflow default to hidden. As long as the columns have a width defined in pixels or percentages it should work.

11-05-2003, 12:07 AM
wonderful!!! That works perfectly. Thanx