tags:

views:

252

answers:

5

When i put a long continuos string in my fixed width td ,it is not getting wrapped. The sting increases the width of my table. Can anybody plz help me with this.

for. e.g. 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.

+3  A: 

you have to use

word-break: break-all

for the td

<style>
   .BreakWord { word-break: break-all; }
</style>

<td class="BreakWord">longtextwithoutspace</td>
rahul
A: 

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)

pavium
A: 

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

James Wiseman
A: 

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.

Keltex
A: 

and for this to work in firefox

word-wrap:break-word;

shruti