W3C home > Mailing lists > Public > www-style@w3.org > October 2003

Re: [CSS21] block formatting context/floats

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 13 Oct 2003 15:03:49 +0000 (UTC)
To: "staffan.mahlen@comhem.se" <staffan.mahlen@comhem.se>
Cc: "www-style@w3.org" <www-style@w3.org>
Message-ID: <Pine.LNX.4.58.0310131334280.29626@dhalsim.dreamhost.com>

On Sun, 12 Oct 2003, staffan.mahlen@comhem.se wrote:
>>
>> In general, formatting contexts grow to contain their in-flow floats, but
>> do not grow to contain out-of-flow content.
>
> If this is generally true i think it may be useful to spell that out
> in the rec (while it may be difficult to describe).

I believe the spec does say this. For example, for floats, in the section
defining the height of a float (10.6.6 Floating, non-replaced elements),
it says:

# In addition, if the element has any floating descendants whose top
# margin edge is above the top established above or whose bottom margin
# edge is below the bottom, then the height is increased to include those
# edges.

For absolutely positioned content (10.6.4 Absolutely positioned,
non-replaced elements, item 3), it says:

# [...] the height is based on the content [...]

...and leaves the exact algorithm up to the UA.

For table cells (17.5.3 Table height algorithms), it says:

# In CSS 2.1, the height of a cell box is the maximum of the table cell's
# 'height' property and the minimum height required by the content (MIN).
# A value of 'auto' for 'height' implies a that the value MIN will be used
# for layout.

...and leaves the exact algorithm up to the UA.


> If i understand correctly, absolutely positioned block formatting
> contexts do not affect containing block formatting contexts, while the
> others do (except for overflow:scroll containing an absolutely
> positioned element?).

There is no overall rule. That's why I said "in general". Basically, each
way of generating a block formatting context has its own rules for
determining its height and its effect on the surrounding flow. The key
about block formatting contexts is how they act inwards, not that they act
outwards. If they were all the same outwardly, they'd all be the same and
there wouldn't be much point in them existing. :-)


> <div style="float: left; width:100px; height: 100px">A float</div>
> <table>
> 	<tr>
> 		<td>A cell</td>
> 	</tr>
> </table>
> I'm not quite sure where in the rec that is defined (and i dont quite
> see why browsers implement it the way they seem to do).

Section 9.5 Floats says:

# The margin box of an element in the normal flow that establishes a new
# block formatting context (such as a table, or element with 'overflow'
# other than 'visible') must not overlap any floats in the same block
# formatting context as the element itself. If necessary, implementations
# should clear the said element by placing it below any preceding floats,
# but may place it adjacent to such floats if there is sufficient space.

-- 
Ian Hickson                                      )\._.,--....,'``.    fL
U+1047E                                         /,   _.. \   _\  ;`._ ,.
http://index.hixie.ch/                         `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 13 October 2003 11:04:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:24 GMT