This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.

Smartphone icons created by Freepik - Flaticon

6.5 CSS Float

The CSS float property specifies how an element should float. The CSS clear property specifies what elements can float beside the cleared element and on which side.

Float Left
Float Right





The float Property

The float property is used for positioning and formatting content e.g. let an image float left to the text in a container. The float property can have one of the following values:

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

float: right;

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

Example 1: float right
img {
  float: right;
}

float: left;

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

Example 2: float left
img {
  float: left;
}

Example - No float

In the following example the image will be displayed just where it occurs in the text (float: none;):

Example 3: float none
img {
  float: none;
}