Demo
- HTML Code:
-
<div></div>
<div id="text">Lorem</div>
- CSS Code:
div {
height: 3px;
background: #dd0;
}
#text { margin: 10px 0; } /* irrelevant to the bug */
First of all, I would like to note that background and margin properties are irrelevant to the bug and are shown in the code only to make it easier for you to associate the code presented with the actual demo elements.
The demo shows two 3 pixel high lines, which are divs. One of them has word "Lorem" in it. The word overflows the second div in any sane browser and in IE7 thus the height of the div stays at 3 pixels.
When the demo above is viewed in IE version below 7 something terrrible is happening, both of our divs are a bit higher than 3px. What is going on? Take a look at the div with word "Lorem" in it. Notice how the div expands to accommodate the word, also notice how the div without any text in it expands to the same height as the div with a word in it.
The bug makes more sense now, even in empty elements IE has at least a space. That "space", due to the broken box model makes our div expand instead of the "space" overflowing out of the div. Let's assume that "space" is a subject to font properties. Now the smartest of you are already trying something after hearing words overflow and font.