English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The CSS float attribute specifies whether a box should float to the left, right, or not float at all.
The following table provides usage instructions and version history of this attribute, as well as the syntax of using this attribute in JavaScript scripts.
Default Value: | none |
---|---|
Applicable To: | All Elements |
Inheritance: | None |
Animatable: | No.Please see Animation Attributes. |
Version: | CSS 1,2,3 |
JavaScript Syntax: | object.style.cssFloat="right" |
The syntax of this attribute is as follows:
float: left | right | none | initial | inherit
The following examples demonstrate how to use the float attribute.
p.red { float: left; } p.green { float: right; }Test to see‹/›
The following table describes the values of this attribute.
Value | Description |
---|---|
left | The element floats to the left. The content starts from the top and flows to the right side of the box. |
right | Similar to left, the difference is that the box floats on the right, and the content starts from the left side of the box, starting from the top. |
none | This box is not floated. This is the default value. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated elements adopt the float attribute value of their parent element. |
Browser Compatibility of float Attribute, the numbers in the following table represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.
|
Please refer to the following tutorials:CSS Float,CSS Alignment.
Position-related Attributes:position,top,right,bottom,left,display,clear.