Word-wrap In An Html Table
Solution 1:
The following works for me in Internet Explorer. Note the addition of the table-layout:fixed CSS attribute
td {
border: 1px solid;
}<tablestyle="table-layout: fixed; width: 100%"><tr><tdstyle="word-wrap: break-word">
LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongWord
</td></tr></table>Solution 2:
<tdstyle="word-break:break-all;">longtextwithoutspace</td>or
<spanstyle="word-break:break-all;">longtextwithoutspace</span>Solution 3:
A long shot, but double-check with Firebug (or similar) that you aren't accidentally inheriting the following rule:
white-space:nowrap;
This may override your specified line break behaviour.
Solution 4:
Turns out there's no good way of doing this. The closest I came is adding "overflow:hidden;" to the div around the table and losing the text.
The real solution seems to be to ditch table though. Using divs and relative positioning I was able to achieve the same effect, minus the legacy of <table>
2015 UPDATE: This is for those like me who want this answer. After 6 years, this works, thanks to all the contributors.
* { /* this works for all but td */word-wrap:break-word;
}
table { /* this somehow makes it work for td */table-layout:fixed;
width:100%;
}
Solution 5:
As mentioned, putting the text within div almost works. You just have to specify the width of the div, which is fortunate for layouts which are static.
This works on FF 3.6, IE 8, Chrome.
<td><divstyle="width: 442px; word-wrap: break-word"><!-- Long Content Here--></div></td>
Post a Comment for "Word-wrap In An Html Table"