Click to See Complete Forum and Search --> : How to force text to wrap?


fischermx
10-26-2008, 11:44 PM
So, I have a table with fixed layout.
I have a column that holds a long string that half of the time will not fit the column.
In Internet Explorer the string wraps nicely. In Firefox, the text just go straight stubbornly making the table look bad.
Now, if I wrap the text inside a "span" it behaves the same way in each browser.
If I wrap the text with a "p" tag, I can style the tag with the same width as the thead and the width is respected now. However, the text still does not wrap in Firefox. Adding "overflow:scroll;" to the "p" style makes the width respected in both browsers but it looks awful with the scroll bars.

How do I force this string to wrap?

Fang
10-27-2008, 06:42 AM
Show the html.

fischermx
11-01-2008, 04:39 PM
Here it is. Just see it in IE7 vs Firefox 3.0 and you'll notice that firefox don't even care about the size.
I mean, if FF doesn't know how to wrap the text, at least trimming it would be more "respectful" for my table-layout fixed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<STYLE type="text/css">
table {
table-layout:fixed;
}

.hostName
{
width:100px;
border:solid 1px green;
}

.hostRow
{
width:100px;
border:solid 2px brown;
}

</STYLE>
</HEAD>
<BODY>

<table>
<th class="hostName">Host name</th>

<tr>
<td class="hostRow">
232.166.205-77.rev.gaoland.net
</td>
</tr>

<tr>
<td class="hostRow">
c-68-41-143-155.hsd1.mi.comcast.net
</td>
</tr>


</table>

</BODY>
</HTML>

Joseph Witchard
11-01-2008, 04:51 PM
I asked a similar question (http://www.webdeveloper.com/forum/showthread.php?t=190287) awhile back. Check that post out, you might find something useful.

Tabo
11-01-2008, 04:51 PM
word-break:break-word; is ie only (i think)

until css 3 comes in there's not much you can do, *but*

using a server side language or manually ever 3 or so characters put a ­ in. this will break the word if needed. you can also use ​ or <wbr /> I'd recomend ­

But I have to say I'm not sure if this will work in tables as columns always stretch to accommodate what's in the cell. This may not be a problem though.

fischermx
11-01-2008, 05:31 PM
joseph:
I don't understand what part of that post would help in this case.

Tabo:
Already tried word-break:break-word; and it doesn't change the behavior in FF.

Joseph Witchard
11-02-2008, 01:30 AM
Did you go to the link that was posted in the thread?

fischermx
11-02-2008, 09:49 AM
Yes, I say that I don't understand what part of the post/thread would help.
The only thing I see is to use "wbr:after { content: "\00200B" }" and I already tried and it didn't work.