Previous examples have shown that the default behavior of blocks is to stack vertically, one above the other, only separated by top/bottom margins if there are any.
The CSS float property causes blocks to float side-by-side.
This is only useful for blocks with widths specified.
Float Left 1
Float Left 2
Float Left 3
Yikes - Still Floating
Yikes - Still Floating
Once you start floating blocks, you have to clear the float to resume normal page layout flow.
Float Right 1
Float Right 2
Float Right 3
Cleared the float again here to resume normal page layout flow.
Remove this clear float in the HTML code and you will see what happens.
Floating several blocks left is very common and is useful for creating columns.
Floating several blocks right is less common and is harder to work with.
Notice the order of the right-floated blocks is reversed from how the divs are placed in the HTML code.
Floating a image left or right is a very common way to get text to flow around the image. This is actually the original purose in adding the float style property to CSS. But developers quickly relized that floating blocks can create columns in a page. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna.