Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

word-wrap does not work in IE

Tags:

css

Word-wrap as follows:

    /* The Breakage of Too Long Words */

div.break_word {
    width: 690px;
    word-wrap: break-word;
}

does wrap the word for the following table, but it also keeps the table stretched:

I used it in this portion of the table:

        <!--  The Contribution Description -->
        <tr>
            <td colspan="3"><div class="break_word"><p><?php echo $contribution_description; ?></p></div></td>
        </tr>

        <!--  The Separation Line -->
        <tr>
            <td colspan="3"></td>
        </tr>

        <!--  The Contribution -->
        <tr>
            <td colspan="3"><pre><div class="break_word"><?php echo $contribution; ?></div></pre></td>
        </tr>

</table>

Does it keep it stretched, because it is overall a table and not a div? Or for which reason does it not stretch back, because the word is indeed wrapped.

like image 853
Carpet Avatar asked Dec 02 '11 14:12

Carpet


People also ask

How do you wrap text in Internet Explorer?

Windows Internet Explorer 8. The -ms-word-wrap attribute is an extension to CSS, and can be used as a synonym for word-wrap in IE8 Standards mode. Use this property to enable the browser to break up otherwise unbreakable strings. This differs from the white-space property, which turns wrapping of the text on and off.

How do you break words in Internet Explorer?

If we use ie7, it could break the long word well. So I suggest you could add the meta tag in html to force the ie using ie7. Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

How to keep html text from wrapping?

If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).

What does white-space pre wrap do?

Collapses white space as for normal , but suppresses line breaks (text wrapping) within the source. Sequences of white space are preserved. Lines are only broken at newline characters in the source and at <br> elements. Sequences of white space are preserved.


1 Answers

As word-wrap is a CSS3 property, it is only supported by IE9 and higher. For IE8 try

-ms-word-wrap

So try

div.break_word {
    width: 690px;
    word-wrap: break-word;
    -ms-word-wrap: break-word;
}

Hope this helps.

Update

It seems that even if you use -ms-word-wrap in IE7, it defaults the white-space: nowrap; which then overrides the word-wrap property.

Once again a IE hack is required. Try adding this for IE7.

white-space: normal; 
like image 178
Sean H Jenkins Avatar answered Oct 21 '22 21:10

Sean H Jenkins