CSS float
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The float
CSS property specifies whether a box should float to the left, right, or not at all.
The following table summarizes the usages context and the version history of this property.
Default value: | none |
---|---|
Applies to: | All elements |
Inherited: | No |
Animatable: | No. See animatable properties. |
Version: | CSS 1, 2, 3 |
Syntax
The syntax of the property is given with:
The example below shows the float
property in action.
Example
Try this code »p.red {
float: left;
}
p.green {
float: right;
}
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
left |
The element float on the left side of its containing block. Content flows on the right side of the box, starting at the top. |
right |
Similar to left , except the box is floated to the right, and content flows on the left side of the box, starting at the top. |
none |
The box is not floated. This is default value. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element float property. |
Browser Compatibility
The float
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS Float, CSS Alignment.
Position-related properties: position
, top
, right
, bottom
, left
, display
, clear
.