Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Box Model and Sizing

The clear property

Reference for the CSS clear property: force an element to start below floated elements on the left, right or both sides. Values, examples and the clearfix.

The clear property tells a block-level element that it must not sit beside earlier floated elements. The element is moved down until its top edge is below the bottom edge of the floats on the chosen side. It is the companion of float.

CSS
.footer {
  clear: both;
}

Try it

Clearing a float

The second note drops below all floats that came before it, so it starts below the red boxes. Without clear, it sits next to the float.

Syntax

CSS
clear: none | left | right | both | inline-start | inline-end
  • Initial value: none
  • Applies to: block-level elements
  • Inherited: no
  • Animatable: no (discrete)
  • Computed value: as specified

Values

Value Description
none The element may sit next to floats on either side.
left The element is moved below any earlier left-floated elements.
right The element is moved below any earlier right-floated elements.
both The element is moved below floats on both sides.
inline-start Clears floats at the start side of the writing direction.
inline-end Clears floats at the end side of the writing direction.

Usage notes

  • Only earlier floats count. An element clears floats that appear before it in the source, not later ones.
  • It is applied to the element after the floats, not to the floats themselves. A float with clear is allowed too, and then it moves below earlier floats on that side.
  • Clearfix. To make a parent contain its floated children, add display: flow-root to the parent, which is simpler and safer than the older pseudo-element trick (::after { content: ""; display: block; clear: both }).
  • Margins. Clearance can swallow a top margin, because the browser positions the element by the clearance needed; if spacing looks wrong, check the margin.
  • Ignored on inline elements. Make the element block-level first.
  • Flex and grid. Floats and clear have no effect on flex or grid items; use gap and alignment instead.

Browser support

Supported in every browser, including the logical values inline-start and inline-end in current browsers.