So I posted here about a firefox bug with rendering margin-top and margin-bottom based on the width of the parent div. Well I was wrong . . . yes I freely admit it. There is no bug in firefox 1.5, or 1.0 or 2.0 or IE 5-7 or Safari or Opera or Linx or any of these. There is a bug with the W3C CSS 2 and 2.1 specification. That's right, you heard me, a bug with the W3C specification.
In any case, I started testing other web-browsers: firefox 1.0, 2.0, Opera, IE, Safari and low and behold . . . they all had the exact same bug. Not wanting to file bug reports at so many places I decided to look up the W3C specification for margins in CSS 2 . . . and what did I find . . . I found the bug:
That's the CSS2 spec, the CSS2.1 Spec of the same thing can be found here:
So . . . explain this to me then . . . if you set top and bottom margins of any element not layed out in a table, the top and bottom margins . . . in percentages . . . are calculated based on the width of the parent element. Hmmmmm, that makes next to no sense . . . so I thought about it a while, and i figured out why they must have decided this.
It makes some sense if you think about it in 2 ways. First If I'm setting an overall margin (using the CSS2 margin shorthand: margin:) and I set it to 10%, I'm expecting to see even margins on both sides. This is a pretty intuitive assumption, if you don't stop to think things through. If you want an even margin, you should set the margin in cm, or em, and if you want an even margin that's relative to the size of the object, you can even you em . . . yes that's right em.
The other reason would be that you might be setting margins to be relative in size to one another: such as 10% for left and right, but only 5% for top and bottom. This could give some odd results if you had . . . let's say, a 10px by 500px div, where the left and right margins calculated to 1px each and the top and bottom margins calculated to 25px each. That would be kind of weird I guess, and a bit unexpected for your average webdesigner.
None the less I think it's weird to do it this way, and I would formally protest to the W3C, except they don't care about me, or what I have to say, because . . . well . . . they are important, and I'm not. I accept this as my fate, and will resign myself to muffled screams and muted anger as I curse their name from the hilltops, and it falls on their deaf ears.
Anyway, that should cover the "fury" part of the blog for awhile.