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

Re: [CSS21] top margin edge - hence static position - is not well-defined

From: Peter Moulder <peter.moulder@monash.edu>
Date: Fri, 01 Apr 2011 22:29:26 +1100
To: www-style@w3.org
Message-id: <20110401112926.GA2575@bowman.infotech.monash.edu.au>
On Sun, Mar 27, 2011 at 03:31:08PM +0200, Anton Prowse wrote:
> 10.6.4 concerning the height of absolutely positioned elements says:
>   # [...] the static position for 'top' is the distance from the top
>   # edge of the containing block to the top margin edge of [...]
> But the vertical margin edges are not well-defined for elements
> whose margins participate in margin collapsing.

My own understanding, perhaps based on

  # In this specification, the expression collapsing margins means that
  # ... margins ... of two or more boxes ... combine to form a single
  # margin.

is that the top margin edge of the box is the top of the combined

I'll grant that this interpretation results in a conflict with
box.html's depiction of a box's margin beginning at the box's border
edge.  (Not just for self-collapsing boxes, but also for some cases
involving min-height/height/max-height properties, where there's no way
of satisfying the height constraints and shared-margin constraints.)

> Where should the absolutely positioned element be drawn in the
> following test case, and why?
> <div style="border-bottom:1px solid; margin-bottom:20px"></div>
> <div style="position:absolute; width:100px; height:100px;
>   background: yellow; margin-top:10px"></div>
> <div style="border-top:1px solid; margin-top:20px"></div>

If we take the static position to be literally the position that it
would be (as distinct from merely a guess) if it had position:static,
then would it be fair to say that the answer is the same as the
position of the yellow box in the above with s/absolute/static/ ?

And yes, that does mean that the yellow of the abspos box (i.e. the
border box, and also the content box) is positioned higher than that of
the corresponding static box.

Thus, I can see the sense of Anton's proposal: the position of the
content or border box is more meaningful for an abspos box than its
margin box, so the intuition is that "same as where it would have been"
should be based on content/border box rather than margin box.

Note that I haven't considered usefulness or the intuitiveness of what
"setting the margin size" should mean.

If we were to adopt the proposal, then could we achieve it by defining
static position in terms of the top border edge instead of top margin

> Happily, there's a natural way of doing this, since the
> general problem illustrated in the test case only affects bottom
> margin, never top margin.  Specifically, when a box's top margin
> collapses with another margin thus contributing to a final margin
> lump, the distance between the box's top border position and the top
> of the margin lump is always at least as great as the box's top
> margin width.

Wouldn't a negative margin width falsify that?  However, I don't really
understand its relevance or how it affects the "meaningfulness" of the
proposed definition, so perhaps I'm misunderstanding something else.

Received on Friday, 1 April 2011 11:30:03 UTC

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