I've used:
word-break:break-all;
table-layout:fixed;
and the text wraps in Chrome but not Firefox.
Update: I decided to change the design so it didn't need the wrap; trying to sort out a CSS fix/hack was proving too frustrating and time consuming.
For an automatic table layout try to style the concerned td combining the attributes max-width and word-wrap.
Eg:
<td style="max-width:175px; word-wrap:break-word;"> ... </td>
Tested in Firefox 32, Chrome 37 and IE11.
Set a column width for the
td
tag.One slightly hackish way of doing this is by processing the text to add space between each letter. Replace spaces with
Then use the letter-spacing css attribute to bring the spaces down.I know, it's a hack... but if NOTHING else works, it should wrap without problem.
I'm using Angular for my project, and managed to solve this with a simple filter:
Template:
Filter:
You can't see it, but after
$1
there is an invisible space (thanks @kingjeffrey for the tip), which enabled word breaks for table cells.Try this, I think this will work for something like "AAAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGG" will produce
I have taken my example from a couple different websites on Google. I have tested this on ff 5.0, IE 8.0, and Chrome 10.
Use CSS3
word-wrap: break-word;
. Works in WebKit based browsers (Safari, Chrome) as well.Update: I forgot, the element in question must however be either implicitly or explicitly positioned as fixed element or displayed as block element. For table cells (
td
), usedisplay: inline-block;
.