English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The clear CSS attribute specifies which side of the element does not allow other floated elements.Learn more.
The following table provides usage instructions and version history of this attribute, as well as its usage syntax in JavaScript scripts.
Default value: | none |
---|---|
Applies to: | All elements |
Inheritance: | None |
Animated: | No View Animation properties. |
Version: | CSS 1,2,3 |
JavaScript syntax: | object.style.clear="left" |
The syntax of this attribute is as follows:
clear: left | right | auto | both | none | initial | inherit
The following example demonstrates how to use the clear attribute.
clearfix:after { content: "."; display: block; height: 0; visibility: hidden; clear: both; }Test and see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
left | The element moves down to clear the past left floating. |
right | The element moves down to clear the past right floating. |
both | The element moves down to clear both left and right floating. |
auto | Do not clear any previously floated elements. This is the default value. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated elements adopt the clear attribute value of their parent element. |
Browser compatibility of clear attribute, the numbers in the table below indicate the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.
|
See tutorial:CSS Float.
Related attributes:float.