Advanced Floats

James Elmore wrote:
> 
> This is one reason why I prefer to separate the ability to 'float' an 
> element into a position and the ability to flow (or 'wrap') elements 
> around the 'floated' element. There are already some good, well 
> documented, reasonably complete, and even implemented ways to position 
> elements. What is lacking is the ability to make other elements move 
> around them as a 'float' does. Why make 'float' more complex when it 
> could just be a shorthand way of saying 'position: absolute left; flow: 
> right;'. (If I got the syntax wrong, I apologize; I just wanted to point 
> out that 'float' is doing two things, and it should be possible to 
> handle the two different things separately, as well as the shorter 
> 'float: left;')

When talking about implementability, one key thing to keep in mind is
that absolute positioning can position things anywhere inside their
container *because* those things don't affect the size of the container.
This is not the case with floats: since they affect the content, they
can affect the size of the container. You can't define a new feature
as "just mix floats and absolute positioning". It creates a circular
dependency.

I agree with Peter Moulder's points about the cost vs. gain for a
"float: center" feature. I don't think we will add it to CSS. I'm not
speaking for the Working Group when I say this, but I very, very much
doubt that we will find the cost of implementing "float: center" worth
the dubious benefit of adding it to the feature list.

However, this isn't to say that more powerful floats aren't something
we'd like to consider. James Elmore posted a list including some other
seriously useful cases we should consider:
   http://lists.w3.org/Archives/Public/www-style/2007Dec/0272.html

Håkon has already started experimenting with ideas for more powerful
floats, particularly in relation to paged media:
   http://www.w3.org/TR/css3-gcpm/#page-floats

If we want to extend something like this to containing blocks other than
the page, note that floating to the top of a box is relatively
straightforward (although it requires a second layout loop), but floating
to the bottom only works without an iterative balancing algorithm if the
containing block is a fixed height.

I think this topic deserves more discussion, but we need to keep in
mind that defining new CSS layout features is more than just evaluating
syntax.

~fantasai

Received on Thursday, 3 January 2008 00:25:13 UTC