# Re: Issue 158 proposed text

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 23 Jun 2010 10:57:06 -0700
Message-ID: <AANLkTinZPOncNcRg59IxPAHX9ZbZwRVLK-Zj227g-UY1@mail.gmail.com>
To: Bruno Fassino <fassino@gmail.com>
Cc: fantasai <fantasai.lists@inkedblade.net>, www-style list <www-style@w3.org>
```Another attempt at resolving http://wiki.csswg.org/spec/css2.1#issue-158 .

For recap, the current relevant section of 9.5.2 reads as follows:
"""
Computing the clearance of an element on which 'clear' is set is done
by first determining the hypothetical position of the element's top
border edge within its parent block. This position is determined after
the top margin of the element has been collapsed with previous
adjacent margins (including the top margin of the parent block).

If this hypothetical position of the element's top border edge is not
past the relevant floats, then its clearance must be set to the
greater of:
* The amount necessary to place the border edge of the block even with
the bottom outer edge of the lowest float that is to be cleared.
* The amount necessary to make the sum of the following equal to the
distance to which these margins collapsed when the hypothetical
position was calculated:
* the margins collapsing above the clearance
* the clearance itself
* if the block's own margins collapse together: the block's top margin
* if the block's own margins do not collapse together: the margins
collapsing below the clearance
"""

I propose replacing this section with the following text:
"""
Computing the clearance of an element on which 'clear' is set is done
by first determining the hypothetical position of the element's top
border edge within its parent block.  This position is determined
after the top margin of the element with all appropriate preceding
margins, per normal margin-collapsing rules.

If this hypothetical position of the element's top border edge is
flush with or past the relevant floats, then no clearance is applied.
Otherwise, the top margin of the element no longer collapses with
preceding margins, and the clearance is set to the greater of:
* The amount necessary to place the top border edge of the block even
with the bottom outer edge of the lowest float that is to be cleared.
* The amount necessary to place the top border edge of the block even
with the previously computed hypothetical position of the top border
edge of the element.  (Informative Note: This is necessary to handle
the case where the float moves due to the element's top margin no
longer collapsing with previous margins.)
"""

additionally clarifies several terms so that the definition is
hopefully fully unambiguous now.  The additional informative note also
makes it clear why the second clause is needed, when a naive reading
would suggest that the second clause is unnecessary due to the
hypothetical position already being established as being *less than*
the float's bottom edge.

~TJ

In particular, here follows an ascii illustration of the test case she
was worried about.  The top box has no margin, while the bottom box
has a large top margin.  The small box is a float that comes between
the other two boxes.

Without clearing, the boxes look like this:

┏━━━━━━━━┓
┃        ┃
┗━━━━━━━━┛
┬
│ (approx 4em)
│
│
┏━━━━━━━━┓
┃┏┓      ┃
┃┗┛      ┃
┗━━━━━━━━┛

With a clear:left set on the bottom box, it *should* look like this:

┏━━━━━━━━┓
┃        ┃
┗━━━━━━━━┛
┏┓        ┬
┗┛        │ (approx 4em)
│
│
┏━━━━━━━━┓
┃        ┃
┃        ┃
┗━━━━━━━━┛

Note that the the bottom box maintains its 4em separation from the top
box.  Only the float moves, as the bottom box's top margin no longer
collapse with the top box's (0px) bottom margin, so there's no longer
anything pushing the float downwards.  The second clause then prevents
the bottom box from gobbling up its own margin in an attempt to line
up flush with the bottom of the float.
```
Received on Wednesday, 23 June 2010 18:05:32 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:36 UTC