The following markup and CSS causes weird behavior in Chrome:
#parent { background: yellow; height: 120px; margin-bottom: 20px; width: 100px; word-wrap: break-word; } #box { background: red; float: left; height: 100px; width: 100%; }
<div id="parent"> <div id="box"></div> <div>OIL</div> </div> <div id="parent"> <div id="box"></div> <div>OWL</div> </div>
Fiddle: https://jsfiddle.net/7sq3ybxr/
The top example (containing the word OIL) causes word breaks, although there is literally no space on the right. Lower - no. I guess this has something to do with character width. In other browsers, the word is always displayed below the field, as expected.
Does anyone know what causes this behavior or is there an idea for a workaround? However, the size, float, and word-wrap properties should remain.
Edit: Oh, by the way, writing markup like this seems to fix it, but thatβs not what I control (imagine user input through tinyMCE):
<div id="parent"> <div id="box"></div> <div> OIL </div> </div>
source share