W3C home > Mailing lists > Public > www-style@w3.org > January 2005

Re: Question on collapsing margins and block reflow context roots

From: Ian Hickson <ian@hixie.ch>
Date: Sun, 30 Jan 2005 00:53:57 +0000 (UTC)
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: www-style@w3.org
Message-ID: <Pine.LNX.4.61.0501300044490.4331@dhalsim.dreamhost.com>

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.


> 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

   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

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:16 UTC