# clear

> The `clear` CSS property specifies whether an element can be positioned next to (and if so, on which sides) floating elements that precede it.

## How do I stop text from wrapping around a float with clear?

The property used to control the behavior of floating elements. It ensures that elements don't wrap around floated elements by moving the element below the floating elements, often used to manage layout and text flow.

- Topic: Alignment & Float
- Type: property
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 1+, Safari iOS 1+

## Example

Wrong:

```css
.sidebar {
  float: left;
}
.footer {
  clear: right;
}
```

Right:

```css
.sidebar {
  float: left;
}
.footer {
  clear: both;
}
```

'clear: right' only clears right floats, so the footer still wraps beside the left-floated sidebar, while 'both' moves it below any float.

## Common mistakes

- Adding empty `<div style="clear: both">` elements to fix layouts.

## Key points

- Parents of floats contain them with `display: flow-root` instead of an empty clearing `<div>`.
- `clear` is set on the element that should move below the float, not on the float itself.

## Interview questions

### What does clear: both do?

It moves the element below any left or right floats that come before it.

### What is a clearfix?

An older hack using `::after` with `clear: both` to make a parent wrap its floats. `display: flow-root` replaces it.

## Related cards

- [float](https://wonderium.dev/css/float.md)
- [Block Formatting Context](https://wonderium.dev/html/block-formatting-context.md)
- [display](https://wonderium.dev/css/display.md)
- [::after](https://wonderium.dev/css/after.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/clear
- Last updated: 2026-11-25
