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

Re: Control over collapsing margins

From: Aryeh Gregor <Simetrical+w3c@gmail.com>
Date: Wed, 29 Apr 2009 09:52:40 -0400
Message-ID: <7c2a12e20904290652h2762ba76hee1e6b2e08896df1@mail.gmail.com>
To: Patrick Garies <pgaries@fastmail.us>
Cc: www-style@w3.org
On Wed, Apr 29, 2009 at 9:33 AM, Patrick Garies <pgaries@fastmail.us> wrote:
> As far as precision control goes, that doesn't solve the problem. If you
> kill the margins that way, you'll always have, at least, one undesired pixel
> of padding; in Mozilla Firefox, Opera, Safari, and Windows Internet
> Explorer, setting the margins to any value that rounds to zero pixels
> results in margins collapsing anyway.

It doesn't seem like Firefox 3.0.10 does that.  Opera 9.50 Alpha and a
packaged Chromium nightly do.  (This is all on Linux.)  See the
attached test case: I get margins collapsing in the first case always,
the second case never, and the third case only in Opera/Chromium.
Things might have changed in more recent Firefox/Opera, of course.

Firefox's behavior here seems the most correct -- the ideal display
would be exactly 0.01px of padding with no margin collapse.
Displaying that as no padding with no margin collapse is only 0.01px
off, which is the best possible rendering if you can only draw whole
numbers of pixels.  Displaying that as no padding with margin collapse
is, in this case, 1em off, which doesn't seem justifiable.  But I'm
not a CSS expert and could easily be missing something.

In case something eats the attachment, I'll post it inline too:

<!doctype html>
<title>Test border collapsing</title>
<style>
div { margin: 1em; background: orange }
p { margin: 1em }
</style>
<div><p>No padding</p></div>
<div style="padding: 1px"><p>1px padding</p></div>
<div style="padding: 0.01px"><p>0.01px padding</p></div>


Received on Wednesday, 29 April 2009 13:53:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 03:46:58 GMT