<?xml version="1.0" ?>Next, anytime I have to adjust for the IE box model, I use the underscore hack. I love this hack cause it isn't removed from the flow of the CSS -- the hack is immediately after the correct declaration so it's easy to A) remember it's there, B) remember to change it when the other changes. This is the underscore hack:
div.className {Everything but IE ignores the underscored declaration.
width: 90px;
_width: 100px;
padding: 0 5px 0 5px;
}
width: 90px;
_width: 80px;
div {
width: 200px !important; /* for good browsers */
width: 180px; /* for IE Windows */
padding: 10px;
}
Explorer ignores !important and so applies the 180px width. Gecko agents (Firefox, Mozilla, etc.), webcore/webkit (Safari, Omniweb, NetNewswire), and Opera honor !important, so they don't apply the later value for width.
Cleaner than some other hacks, and is future-proof assuming that Explorer's box model and parsing errors get fixed in the same release.
posted by nathan_teske at 2:32 PM on October 5, 2004