tags:

views:

36

answers:

2

in a td of a table i have a very long single word "Pneumonoultramicroscopicsilicovolcanoconiosis" and i want to reduce the width of table but unable to do because of this long word in one of the td i can break this word by giving <br /> but is there any CSS way to break this word according to available space. without giving line break or edit anything in HTML.

+2  A: 
td span{display:block;width:your_max_width_here.px}

<td><span>Pneumonoultramicroscopicsilicovolcanoconiosis</span></td>
nicholasklick
+1 thx for this solution. is there any possibility of other way through pure CSS bcoz table is auto generated by CMS so i can't add `<span>`
metal-gear-solid
@metal-gear-solid So wrap your value first with 'max-width'd span in your data source before you show it to html.
Jeaffrey Gilbert
+3  A: 

Try the following:

word-wrap: break-word;
white-space: normal;

word-wrap is css3 (however it works in IE). You might not be able to get it working in older browsers however.

Ben Rowe
I believe `word-wrap` support goes all the way back to IE5!
adam
@adam yeah, that sounds about right :)
Ben Rowe