.wee {
float: left;
padding: 0;
margin: 0;
background: #eee;
border: 1px solid #000;
width: 20%;
}
* html body .wee {
margin-right: -3px;
}
.text {
margin: 0;
padding: 0;
background: #ccc;
}
One of the most interesting "features" of Internet Explorer 6 (and lower versions) is its complete misunderstanding of the often overused 'float' property. Basically, when Internet Explorer parses a float declaration, a property called hasLayout comes into play. Results are strange: Internet Explorer can double the margin of a floated element, or add 3 pixel to this margin. Sometimes, when you declare a negative margin, Internet Explorer can make the floated element disappear from viewport.
Usually we have only a few ways to fix this problem, according to this article:
Both methods fail in this study. Nothing happens, and the extra space lies silent between the floating div and the element next to float. Note that both margin and padding of the elements are set to 0. Only one way's left:
.wee {
margin-right: -3px;
}
This works fine with Internet Explorer but not with the other browsers, which make the non-floated element overlap the floating div. Here comes into play the so-called star-HTML hack, a simple trick that exploits a dummy Internet Explorer's misunderstanding of the W3C DOM (Document Object Model). Everyone on the Web knows that the root element of an HTML document is actually <html>. Everyone but Internet Explorer. It "thinks" that the root element is an "UHO" (Unidentified HTML Object) surrounding the <html> element. Strange but true. So a nonsense declaration like:
* html body element {...}
is perfectly clear for Internet Explorer (and ignored by the others). With the universal selector we get first the mysterious root element and then, using the descendant selectors, we find our way to reach the element we want to fix (here .wee).
In the end:
For a long time there was none, beyond the voice of a weak bird singing a trite old evening song that might doubtless have been heard on the hill at the same hour, and with the same trills, quavers, and breves, at any sunset of that season for centuries untold.
- Thomas Hardy