Learn CSS3 to style your web pages

Know what is CSS, its uses and how to add? CSS Style for Text, Paragraphs, Tables, Links and Forms. Background image with CSS, Borders styles in CSS, Set margin and positions in CSS, etc.

CSS Float and Clear

The float Property

The float property specifies whether or not an element should float.

In its simplest use, the float property can be used to wrap text around images.

The following example specifies that an image should float to the right in a text:

See this example:

img {
    float: right;
    margin: 0 0 10px 10px;

The clear Property

The clear property is used to control the behavior of floating elements.

Elements after a floating element will flow around it. To avoid this, use the clear property.

The clear property specifies on which sides of an element floating elements are not allowed to float:

See this example:

div {
    clear: left;