W3C home > Mailing lists > Public > www-style@w3.org > April 2009

Re: Control over collapsing margins

From: James Elmore <James.Elmore@cox.net>
Date: Wed, 22 Apr 2009 08:53:46 -0700
Message-Id: <41376C1C-B09B-419A-8173-0BDE96F67CAA@cox.net>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Niels Matthijs <niels.matthijs@internetarchitects.be>, www-style@w3.org
To: David Hyatt <hyatt@apple.com>

On Apr 22, 2009, at 8:33 AM, David Hyatt wrote:

> On Apr 22, 2009, at 9:55 AM, Tab Atkins Jr. wrote:
>> On Wed, Apr 22, 2009 at 5:27 AM, Niels Matthijs
>> <niels.matthijs@internetarchitects.be> wrote:
>>> Hi all,
>>> I was reading up on collapsing margins as they've been causing me  
>>> quite some trouble. Whenever a child element has a different  
>>> background styling from its parent, collapsing margins are  
>>> usually troublesome. The collapse is broken by padding and  
>>> borders, but not by different style of background (which also  
>>> indicates separation).
>>> Rather than change the rules for collapsing, I wonder if it  
>>> wouldn't be better to give css people the opportunity to manage  
>>> them themselves if needed. In short, introduce a new property  
>>> which can break the collapse when needed, because adding unneeded  
>>> borders, paddings or overflows is really not the way to go.
>>> Further explanations of my view can be found in the following  
>>> article:
>>> http://www.onderhond.com/blog/work/collapsing-margins-improvement
>>> I apologize if this issue was already raised, but couldn't find  
>>> any information about it.
>> I know that a property to indicate that an element should form a  
>> block
>> formatting context has been suggested before.  That would prevent
>> margins from collapsing, as well as doing a few other things.  Would
>> that be acceptable?
>> I agree that the ability to stop margin collapsing at will would be
>> occasionally useful.  I've had to hack around the problem with 1px
>> padding or border before as well.
>> ~TJ
> These properties exist in WebKit.  I proposed them for  
> standardization back when I implemented them and got a lukewarm  
> response, so never followed up.  I'll propose them again now in  
> case there is more interest.

This is good to know. I wonder how I missed this before. Did the  
style list have some sort of announcement? Or is there some place  
where new 'features' are listed, beyond the list?

> -webkit-margin-top-collapse
> -webkit-margin-bottom-collapse
> Supported values are:
> collapse - Do the collapse as normal.
> separate - Don't collapse.
> discard - Do the collapse and discard the entire result (this is  
> actually how margins in table cells work for many HTML elements in  
> quirks mode).

This works for English, but not for other 'stacking orders' Also, a  
single property which collapses both before and after margins would  
be nice. Is there any call for margin collapsing on elements which  
are side-by-side (other than other languages)?

Note: the addition of 'discard' is something I had not considered.  
Have you received any feedback (positive or negative) as to its  
utility? When I proposed something similar (without the 'discard') I  
simply assumed that the designers would set margins to 0 if they  
wished to discard them, but I like the sense of completeness this  

> dave
> (hyatt@apple.com)

Dave, is there some place where the additional features of webkit are  
listed and explained?


Received on Wednesday, 22 April 2009 15:54:32 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:35 UTC