Re: Question on collapsing margins and block reflow context roots

On Fri, 28 Jan 2005, Boris Zbarsky wrote:
> > You can get very close with real CSS:
> >    http://junkyard.damowmow.com/173
> > ...with minimal amounts of extra-CSS, I don't see the problem.
> 
> The minimal extra CSS for that case is something like "fieldset border 
> doesn't paint behind the legend element" or something and is very hard 
> to pin down if people change the position on the legend or its offsets 
> (as in, what should the behavior really be, then?).

Indeed. It could also be done simply by having the "legend" element be 
position: -moz-over-parent-border, and having the border code check to see 
if the first element has that, and if so, don't paint the border on the 
overlap. Sure, it's not easy. Why do you think it's not in the spec? ;-)


> > It shouldn't be a block formatting context root.
> 
> OK.  Forget that <fieldsets> are involved.

Ok.


> Should the margins of a block formatting context root collapse with its 
> children, in general?

Insofar that the default behaviour for margins is for them to collapse 
with adjacent margins, yes.

Exceptions are specifically made for:

   overflow boxes: The inner margins can scroll independently, so 
   collapsing would be confusing at best.

   root elements: backwards-compatibility reasons (primarily 
   livejournal.com's stylesheet in mid 2004) required that the spec
   exempt the root element's margins from collapsing with children.

   absolutely positioned elements and floats: the margins on these are
   used to offset the boxes, so collapsing them would lead to confusing
   cases.

   inline-blocks: margins of these don't collapse, for compatibility with
   the implementation in WinIE (which isn't really inline-block, but was
   used as a guide for some of the ways they work).

   table cells: they have no margins.

...which happens to be all of the current block formatting context roots, 
but that's a coincidence.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Sunday, 30 January 2005 00:54:00 UTC