W3C home > Mailing lists > Public > www-style@w3.org > October 2008

RE: [CSS21] Collapsing Margins

From: Alex Mogilevsky <alexmog@microsoft.com>
Date: Tue, 7 Oct 2008 20:03:22 -0700
To: Boris Zbarsky <bzbarsky@MIT.EDU>, fantasai <fantasai@inkedblade.net>
CC: Arron Eicholz <Arron.Eicholz@microsoft.com>, "www-style@w3.org" <www-style@w3.org>
Message-ID: <7C2F64B551D8664AAD94A28DAC37D020670582791D@NA-EXMSG-C103.redmond.corp.microsoft.com>

I don't think we came to a conclusion on this thread. Elika - can we add this to 2.1 issue list?

On the issue:

I was wrong in What I said earlier about IE8 being correct. At least not exactly. As of now, IE doesn't currently have code for min-height to conditionally have effect on margin collapsing (preventing collapsing of bottom margin *if* min-height has an effect). We currently only check if min-height is non-zero, and if so it prevents margin collapsing through its bottom edge. While that first decision is apparently not standard, it makes the second one obvious - last child's margin affects parent's height rather than being ignored.

I think we still need to have a clarification in the spec. I tend to prefer the answer where margins are actually used and min-height doesn't reduce height. However I will admit that duplicating Firefox behavior would be easier.

-----Original Message-----
From: Boris Zbarsky [mailto:bzbarsky@MIT.EDU]
Sent: Wednesday, September 10, 2008 12:12 PM
To: Alex Mogilevsky
Cc: Arron Eicholz; www-style
Subject: Re: [CSS21] Collapsing Margins

Alex Mogilevsky wrote:
> What I mean to say there is that the meaning of margin is to define the distance between elements.

More precisely, the meaning of margin is to define a spacing around a
given element.

> Consider this:
>         <C>
>                 <A/>
>         </C>
>         <B/>
>
> If element A has bottom margin of 80px, it would normally mean that it will be at least that far from element B that follows. That may change A has a parent C with certain properties. Specified 'height' on C clearly can reduce this distance, as can 'max-height'. However having 'min-height' reduce overall size of layout seems odd.

Yeah.  That's just life with collapsing margins.  Say you have:

   Text
   <div>
     <div style="height: 20px; margin-bottom: 80px"></div>
   <div>
   More text

There are 80px of space between the two pieces of text, but if the
height of the outer div is set to 21px (which is bigger than its used
height!), there will be 21px of space between the two pieces of text.

The min-height case is no different from this, basically.

Now you can claim that really collapsing margins just don't work that
well once you're not doing auto heights, and that's true, in my opinion.
  that's not the use case they were designed for.

-Boris
Received on Wednesday, 8 October 2008 03:04:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:15 GMT