E-Mail:

Why does the CSS box model need a hack?

I am willing to bet tomorrow’s lunch money that you have found yourself wondering at least once why the CSS box model needs a hack? OK, I just tossed that out there, call it fishing if you like. Regardless, this article on “hacking the CSS box model” is quite informative, even if you are already familiar with such a method of working with this instance.

According to the W3C, an assigned ‘width’ (and ‘height’) of a box refers to the ‘content area’ of a box only. The padding, borders, and margins are then added to this value to arrive at the total box width. If the ‘width’ property is omitted, the total box width is the same as the ‘content area’ of the surrounding container element.

All well and good. Unfortunately, all CSS enabled versions of IE before IE6/strict use a different box model. In that model, the padding and borders are counted as part of any assigned ‘width’ or ‘height’. In the absence of borders and padding, the two models agree. However, if a box has an assigned “width’, and if borders and/or padding are added, the standard box model causes the overall box width (between the outer border edges) to increase, while in IE’s model the ‘content area’ gets squeezed by the same amount. This is a major problem for proper page layout.

What Do You Think?

 

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

Flash, SEO - Aug 6, 2008

Flash And SEO: Like Oil And Water

68 queries / 0.387 seconds.