Re: Control over collapsing margins

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 UTC