The diary and photos of Chris Beach. I'm into windsurfing, coding, badminton, drawing and composing music using computers and synths.

If you have any opinions about these quotes then vote on the quotes page. Here's another:
"Religion is regarded by the common people as true, by the wise as false, and by the rulers as useful." Seneca the Younger 4 b.c.- 65 a.d.


switching to internet explorer's box model

In CSS/HTML it seems logical to me that the width of an element should be independent of the padding applied within it. If I change the amount of internal padding within an element, I don't want the width of the element to be affected. Unfortunately, the W3C has decided that width is dependent on padding, and the minority browsers (Firefox, Opera et al) render in this illogical style.

Even though IE5PC gets the box model WRONG according to the W3C spec, I actually like their way of doing it better. It makes it MUCH easier to add up percentages. With the spec's version of the box model, if I have two boxes side by side of equal width, I could set them at 50% each and be happy. But... if there is a border, a margin or some padding involved, I have to decrease that 50% value to account for those elements. However, those elements are generally NOT calculated by percentages, because it just doesn't look right. How do you subtract (2px) + (10% * 2) + (4ex * 2) from 50%? Yeah... exactly... you can't

revjim.net

Internet Explorer's box model makes much more sense to me, and thankfully there is a way to switch the minority browsers to this mode of rendering. Insert the following snippet of CSS into your stylesheet and your box model woes are over:

* { box-sizing:border-box; -moz-box-sizing:border-box }

The box-sizing declaration is part of a proposed W3C CSS3 spec, and has been implemented in Opera, IE for Mac, Mozilla and Firefox. As with most of their CSS3 support, Mozilla have attached their dastardly vendor-specific -moz- prefix.

[some alternatives]

written by Chris Beach
06/07/05 06:31pm
(4 years, 7 months ago)

comment9 comments

photoadd photo

post to del.icio.usdigg it!permalink

66 links

[view more journal entries from tech journal]


Pulled from cache