How can I make Firefox word-break with CSS?

zjm1126 picture zjm1126 · Nov 26, 2010 · Viewed 61.9k times · Source

This is my code so far:

<div style="width:100px;height:100px;background:red">
            ssssssssssssssssssssssssssssssssssssss
</div>

However,

word-wrap:break-word;
word-break:break-all;

does not prove useful, since it can't word-wrap on Firefox. What can I do, using CSS?

Answer

Swadesh Behera picture Swadesh Behera · Sep 2, 2012
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
width:200px;

The above piece of code works for me wonderfully