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

Re: Collapsing vertical margin through parent. why?

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 15 Oct 2003 11:54:09 -0500
Message-ID: <3F8D7BB1.9020906@mit.edu>
To: Michael Favia <michael.favia@insitesinc.com>, www-style@w3.org

Michael Favia wrote:
> I was wondering if there is any reason that the vertical margins of a
> block level element should collapse through the content block of its
> parent. 

Consider the following markup:

<section>
   <para>This is the first paragraph</para>
   <para>This is the second paragraph</para>
</section
<section>
   <para>This is the third paragraph</para>
   <para>This is the fourth paragraph</para>
</section

and the CSS:

section { margin: 2em 0 }
para { margin: 1em 0 }

Should the space between the two sections be 2em or 4em?

The idea is that margins serve to separate content and that the biggest 
separation applicable should take effect rather than adding up all the 
separations.  This leads to mostly intuitive results when writing 
documents and marking them up with CSS -- people don't want the spacing 
between their sections depending on the contents of the section, 
typically, unless the contents really need more spacing around them than 
sections already have by default.

-Boris
Received on Wednesday, 15 October 2003 12:59:42 GMT

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