The Dopefly Tech Blog

« The Dopefly Tech Blog Main page

IE layout problems fixed

posted under category: Standards on October 4, 2006 at 1:00 am by Nathan

If you saw this site in the last couple days with IE6, you saw the box model problem they always talk about. I liberally use padding in my stylesheets. Padding, of course, is the space between the border of an area and the content within that area. When you specify a width and a padding size, you are supposed to subtract the width of that padding (on each side), and your margins and borders to get the size of your area. However, IE6 doesn't really abide by this law.

It's a fairly simple fix, thankfully.

div#content {
padding:0 25px;
width:500px;
}
html>body div#content {
width:450px;
}

The more specific html>body rule overrides the cascading width for browsers who know how to obey rules.