This is actually getting interesting.
First, I asked myself: "Could it be a hasLayout
issue?" (An old related issue)
Hence I made a test on JSBin, and checked the result on IE8 (Windows7).
But I faced an strange behavior.
In that Demo, word-wrap: break-word;
doesn't work properly on an inline
element such as <a>
tag. But if you set that on the parent (<div>
element) it works!
While the MSDN states that this property will be applied to all elements.
Once you change display
property of that inline element to block
it would work without error.
On the other hand, There's a same situation for using word-break: break-all;
on an inline
element; it won't work.
But when we change the display
property of the element to inline-block
or block
, it works well.
I don't exactly know why this happens. (In my knowledge) The spec doesn't stated anything about this.
But if those two CSS declarations are set on the container, they'll work on different web browsers (IE as well):
div { /* <-- the container */
word-wrap:break-word;
word-break:break-all;
/* other styles... */
}