Avoiding Tantek's "Box Model Hack" | August 13, 2003
If you're a CSS developer you'll know that IE5.x gets the box model wrong. Padding and margin should actually be added to the width of a box. However IE5.x includes padding and margin within the width of the box. An annoying bug that can really mess with ones layout.
Luckily Tantek Celik came up with a clever, ugly hack to get round this issue. I've used this hack on a number of sites but, when building the new message site, I found a much more elegant solution.
Somebody on a web design forum (can't remember who or where) suggested that in most cases you didn't really need to use this hack. What you do is simply set the padding/margin of the element your interested in, and then set the width on the parent element. This may mean creating a parent element (a wrapper div) solely for this purpose. Not great, but much less messy than using the box model hack.
Posted at August 13, 2003 5:43 PM
Bryant said on August 13, 2003 6:04 PM
I think Tantek’s hack is actually a Good Thing because it places the hack in the CSS, not the page source. One of the big plusses to the XHTML + CSS combination is that styling changes are made by editing your site’s CSS file instead of each HTML page individually. When IE 5.x ceases to be an issue (perhaps in 2010 or so) the hack can be removed from a single CSS file, instead of manually stripping hundreds of non-semantic divs from your XHTML.