Reputation: 721
When I put a long continuous string in my fixed width td, it is not getting wrapped. The string increases the width of my table. Can anybody please help me with this.
For example:
this is my text --- works fine as in td width is fixed only height increases
but if I insert
thisismytext --- then it increases the width of my table.
Upvotes: 4
Views: 3054
Reputation: 15138
In other words, give the browser an excuse to break the line (by including spaces in the contents) and it will. Force it to use one line (by omitting spaces) and it increases the width of the table.
In the absence of any extra layout rules, what else could it do?'
Edit: there may be cross-browser problems with word-break / wbr (it seems to be CSS3, now, but was formerly an IE invention)
Upvotes: 0
Reputation: 26446
Use the <wbr>
tag in your text every few characters (20? 30? you'll need to experiment). This will allow breaks in your text without spaces. Like this:
<td>LongLongLong<wbr>TextTextText</td>
This will be all strung together unless a break is needed.
Upvotes: 0
Reputation: 30530
If your text and cell width is fixed you could add a
<td>My text<br />on a different line</td>
Something I've found sometimes happens is that the text is wrapping, just the td height hide this
Upvotes: 0
Reputation: 187110
you have to use
word-break: break-all
for the td
<style>
.BreakWord { word-break: break-all; }
</style>
<td class="BreakWord">longtextwithoutspace</td>
Upvotes: 14