display: flow-root example

A new value of the display property that will enable containers to clear floats. Needs Chrome Canary or Firefox Nightlies.

Default behavior

The following item is a wrapper containing a block that is floated left.

Example one

The border on the containing block only wraps the text as the floated element is taken out of flow.

The content following the box will also rise up and wrap around the float unless we set it to clear.

The clearfix hack

In this next item we use a clearfix hack to cause the wrapper to clear the floated item.

Example two

Using display: flow-root

CSS now has a way to cause elements to clear floats. We set the value of display to flow-root and our floated box is cleared.

Example three