W3C home > Mailing lists > Public > www-style@w3.org > November 2012

Re: Float clearing a float when inside a self-collapsing block with margin-top

From: Øyvind Stenhaug <oyvinds@opera.com>
Date: Tue, 27 Nov 2012 10:28:48 +0100
To: "Robert Hogan" <robhogan@gmail.com>
Cc: www-style@w3.org
Message-ID: <op.wofdyatpbunlto@oyvinds-desktop>
On Mon, 26 Nov 2012 20:12:46 +0100, Robert Hogan <robhogan@gmail.com>  

> It seems like the correct position of the black float in this snippet
> is directly below the blue float:
> <p>The blue box should be stacked on top the black box.</p>
> <div style="height: 20px; width:20px; float:left; background:  
> blue;"></div>
> <div style="margin-top:10px; clear:both;">
>     <div style="height: 20px; width:20px; float:left; background:  
> black;"></div>
> </div>


> However if we follow http://www.w3.org/TR/CSS21/visuren.html#clearance
> the outer top of the black float's parent (which is a self-collapsing
> block) should be halfway down the blue float, because the remaining
> 10px of the blue float's height is accounted for by the
> self-collapsing block's 10px of top-margin.


> So with this in mind, it's not clear to me what, in the spec, forces
> the black float to only go as far as the top border edge of its parent
> (so that it clears the blue float completely) rather than the outer
> top of its parent as it would normally do (where it will avoid the
> blue float rather than clear it).

I'm not sure why you say that's what it would normally do. The top of the  
black float may not go higher up than the content edge of its parent, per  
<http://www.w3.org/TR/CSS21/visuren.html#float-rules> and  

Øyvind Stenhaug
Opera Software ASA
Received on Tuesday, 27 November 2012 09:29:21 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:06 UTC