RE: [CSS21] Collapsing Margins

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 UTC