Okay, this is really confusing me. I have some content inside of a div like so:
<div style="background-color: green; width: 200px; height: 300px;">
Thisisatest.Thisisatest.Thisisatest.Thisisatest.Thisisatest.Thisisatest.
</div>
However, the content overflows the DIV (as expected) because the 'word' is too long.
How can I force the browser to 'break' the word where necessary to fit all of the content inside?
Best Answer
Useword-wrap:break-word;
It even works in IE6, which is a pleasant surprise.word-wrap: break-word
has been replaced withoverflow-wrap: break-word;
which works in every modern browser. IE, being a dead browser, will forever rely on the deprecated and non-standardword-wrap
instead.Existing uses of
word-wrap
today still work as it is an alias foroverflow-wrap
per the specification.