Re: [css2.1] Issue 158 and Issue 178 Resolution

On Thu, Aug 5, 2010 at 2:22 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> Change 3
> --------
>
> In section 9.5.2, at the end of the paragraph starting "Computing the
> clearance of an element...", delete from "previous adjacent margins"
> to the end of the sentence.  Replace it with "adjoining margins,
> according to the margin-collapsing rules in 8.3.1".

I thought that this change would make the text sync up with
implementations.  It does, but only partially.

Firefox and Opera follow the current text, and only pay attention to
"previous adjacent margins" when this case comes up.

IE and Webkit follow my newly proposed text, and pay attention to all
adjoining margins when this case comes up.

Test case here:

<!DOCTYPE html>
<title>Test</title>
<style>
body { margin: 0; }
</style>
<div style="float: left; width: 100px; height: 100px;
background-color: green"></div>
<div style="clear: left; margin-top: 10px; margin-bottom: 40px;
outline: 2px solid orange;"></div>
<div style="background-color: blue;">I'm a helper element.</div>

By CSS2.1, section 9.5.2, the current spec text ("previous adjacent
margins") means that you only use the 10px margin-top to determine the
clearance amount, and so get 90px of clearance.  Then, when
positioning the blue div, you use the full collapsed margin of 40px.
40px+90px = 130px, so the blue div starts 130px from the top, and has
a 30px gap between it and the cleared element.  This is Firefox/Opera
behavior.

My new suggested spec text says to use "adjoining margins", which
includes the 40px bottom margin.  So you get 60px of clearance, and
the blue div ends up 100px from the top, with no gap between it and
the cleared element.  This is the IE/Webkit behavior.

Quite a lot in this section is totally arbitrary in the first place,
so neither option makes more sense than the other.  Thus, I suggest
going with my change, as it's the option that IE and Webkit have
taken.

I'd be very interested if anyone can come up with a case showing that
my interpretation of the behavior here is incorrect, and that the
discrepancy is in fact caused by something else.

~TJ

Received on Friday, 6 August 2010 01:29:24 UTC