W3C home > Mailing lists > Public > www-style@w3.org > July 2010

Re: [CSS 2.1] [section 9.5 Floats] Empty floated element with a set width but height:0

From: Anton Prowse <prowse@moonhenge.net>
Date: Fri, 30 Jul 2010 23:14:08 +0200
Message-ID: <4C5340A0.8090802@moonhenge.net>
To: www-style@w3.org
CC: www-style@gtalbot.org
Gérard Talbot wrote:
> 
> Does an empty floated element with a set width occupy an horizontal space
> on a line?
> 
> Testcase:
> 
> http://www.gtalbot.org/BrowserBugsSection/css21testsuite/floats-107-gt.html
> 
> According to Ian Hickson, div#zero-height-first-float should occupy an
> horizontal space (6em) on the line... but all mainstream browsers (IE8,
> Firefox 3.6.8, Opera 10.60, Chrome 5.0, Safari 5.0, Konqueror 4.4.5) do
> not allocate an horizontal space to that div#zero-height-first-float .

(We're talking about zero-height floats, rather than empty floats.)

The following may be useful for comparison.

<div style="line-height:20px; width:200px">
	<div style="float:left; height:20px; width:100px"></div>
	text text text text text text text text text text text text text
</div>

Only one line box is shortened by the float; in particular, the second
is not shortened.  Is there really any difference between that and

<div style="line-height:20px; width:200px">
	<div style="float:left; height:0; width:100px"></div>
	text text text text text text text text text text text text text
</div>

in which browsers decide that no line box is shortened by the float?

It just boils down to what is regarded as being "next to" the float.
 From 9.5:

   # line boxes created next to the float are shortened to make room for
   # the margin box of the float

Cheers,
Anton Prowse
http://dev.moonhenge.net
Received on Friday, 30 July 2010 21:15:47 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:29 GMT