Re: [CSS 2.1] Margins and absolutely positioned elements

--- "�istein E. Andersen" <>

> §10.6.4 in the CSS 2.1 specification [1] says:
> > 2. [If] 'top' and 'bottom' are 'auto' and 'height'
> is not 'auto', then set 'top' to
> > the static position, set 'auto' values for
> 'margin-top' and 'margin-bottom'
> > to 0, and solve for 'bottom'

You might want to reread the bit about how the static
position is calculated.

> §8.3.1 [2] gives the following precision:
> > Margins of absolutely positioned boxes do not
> collapse
> This is not, however, quite as specific as what is
> said about floated elements:
> > Vertical margins between a floated box and any
> other box do not collapse

That's just a difference in wording; in the first one,
"with any other box" is implied, and only vertical
margins can collapse.

> This leaves me quite confused. Does §8.3.1 affect
> §10.6.4 in this case?

The margins don't collapse; absolutely positioned
elements without an explicit position use the static
position to calculate their position.  The margin is
then added to this value.  It isn't too hard once you
understand how the static position is calculated. 
(Note that the top margin edge of a box does not
depend on its margin.)

> (Apparently, browsers do dot €˜collapse€™ margins
> in the CSS sense, but rather
> choose to take into account or not the margin on the
> non-absolutely
> positioned element when the position of the
> absolutely positioned element
> is calculated.)

IE6 is rendering this incorrectly; Firefox and Opera
get it right as far as I can tell.


TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.

Received on Saturday, 7 April 2007 11:28:42 UTC