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

Re: [CSS21] Collapsing Margins

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 10 Sep 2008 15:11:44 -0400
Message-ID: <48C81BF0.2030406@mit.edu>
To: Alex Mogilevsky <alexmog@microsoft.com>
CC: Arron Eicholz <Arron.Eicholz@microsoft.com>, www-style <www-style@w3.org>

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, 10 September 2008 19:12:32 GMT

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