CSS clear Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout & Floats

What You’ll Learn

The clear property controls how elements behave around floated content. It helps you fix overlap and keep footers, paragraphs, and sections in the right place.

01

Float Layout

Works with floated boxes.

02

Syntax

Direction keywords.

03

none Default

No clearing by default.

04

both

Clear all floats.

05

left / right

Clear one side only.

06

Clearfix

Classic layout pattern.

Definition and Usage

The clear CSS property controls the behavior of elements around floating content. When elements are floated using the float property, they are removed from normal document flow and other content can wrap beside them.

The clear property specifies whether an element should be moved below (cleared) floating elements that precede it. This prevents unwanted overlap and keeps your layout readable.

💡
Beginner Tip

Think of float as pulling boxes to the side, and clear as telling the next element, “Start on a new line below those floated boxes.”

📝 Syntax

The syntax for clear is straightforward — you choose which floats to clear:

syntax.css
selector {
  clear: value;
}

Basic Example

clear-both.css
.footer {
  clear: both;
}

Syntax Rules

  • The initial value is none.
  • Values: none, left, right, both, inline-start, inline-end.
  • Apply clear to the element that should drop below preceding floats.
  • Works with elements that have float: left or float: right above them.
  • Modern layouts often use Flexbox or Grid, but clear remains essential for float-based designs.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toBlock-level and floated elements
InheritedNo
AnimatableNo
Common useFooters and sections below floated images or columns

💎 Property Values

The clear property accepts keyword values that describe which floats to move past.

ValueExampleMeaning
noneclear: none;The element is not moved down to clear past floating elements. This is the default.
leftclear: left;The element is moved down to clear past left-floating elements.
rightclear: right;The element is moved down to clear past right-floating elements.
bothclear: both;The element is moved down to clear past both left- and right-floating elements.
inline-startclear: inline-start;Clears floats on the start side of the inline direction (logical equivalent of left in LTR).
inline-endclear: inline-end;Clears floats on the end side of the inline direction (logical equivalent of right in LTR).
none left right both inline-start inline-end

clear and float Together

clear only matters when floats exist above an element in the document. Typical workflow:

  1. Float images, sidebars, or columns with float: left or float: right.
  2. Content that follows may wrap beside those floats.
  3. Apply clear on the next block that should start below all floats — often a footer, heading, or full-width section.

A common pattern is the clearfix: a helper element (or pseudo-element) with clear: both placed after floated children so a parent container expands to contain them.

👀 Live Preview

Compare what happens without clear versus with clear: both on the content block below two floated boxes.

Without clear (content wraps beside floats)

Box 1
Box 2
This content wraps beside the floated boxes because clear is not set.

With clear: both (content drops below)

Box 1
Box 2
This content moves below both floated boxes because clear: both is applied.

Examples Gallery

Try clear: both, side-specific clearing, a floated image layout, and a footer clearfix pattern.

📝 Basic Clearing

Start with the reference example — two left-floated boxes and a cleared content block below them.

Example 1 — clear: both with Floated Boxes

Ensure a section moves below floating boxes on both sides.

clear-both.html
<style>
  .box {
    width: 100px;
    height: 100px;
    margin: 10px;
    float: left;
    background-color: lightblue;
  }
  .clear {
    clear: both;
    background-color: lightgreen;
    padding: 10px;
  }
</style>

<div class="box">Box 1</div>
<div class="box">Box 2</div>
<div class="clear">Cleared Content</div>
Try It Yourself

How It Works

The clear: both rule moves “Cleared Content” below both floated boxes instead of wrapping beside them.

Example 2 — clear: left

Clear only left-floating elements while still allowing content beside right floats.

clear-left.html
<style>
  .float-left { float: left; width: 80px; height: 80px; background: #fde68a; }
  .float-right { float: right; width: 80px; height: 80px; background: #fbcfe8; }
  .clear-left { clear: left; background: #e0e7ff; padding: 8px; }
</style>

<div class="float-left">Left</div>
<div class="float-right">Right</div>
<div class="clear-left">Clears left float only</div>
Try It Yourself

How It Works

clear: left drops the element below left floats but does not necessarily clear right floats on the same line.

🖼️ Layout Patterns

Use clear in real page layouts with floated images and footers.

Example 3 — Floated Image with clear: right

Place a caption block below a right-floated image using clear: right.

clear-right.html
<style>
  img {
    float: right;
    width: 120px;
    margin: 0 0 8px 12px;
  }
  .caption {
    clear: right;
    font-size: 0.875rem;
    color: #64748b;
  }
</style>

<img src="photo.jpg" alt="Sample">
<p>Text wraps beside the image on the left.</p>
<p class="caption">Caption clears below the image.</p>
Try It Yourself

How It Works

The caption paragraph uses clear: right so it starts below the right-floated image instead of beside it.

Example 4 — Footer with clear: both (Clearfix Pattern)

Drop a full-width footer below a row of floated columns.

clearfix-footer.html
<style>
  .column {
    float: left;
    width: 30%;
    padding: 10px;
    background: #dbeafe;
  }
  footer {
    clear: both;
    background: #1e293b;
    color: #f8fafc;
    padding: 12px;
  }
</style>

<div class="column">Col 1</div>
<div class="column">Col 2</div>
<div class="column">Col 3</div>
<footer>Site footer — full width below columns</footer>
Try It Yourself

How It Works

Without clear: both on the footer, it could overlap or sit beside the floated columns. Clearing forces it to start on a new line below them.

🧠 How clear Works

1

Elements are floated

Images, boxes, or columns use float: left or float: right and leave normal flow.

float
2

Following content may wrap

Without clearing, the next block can sit beside floats and create cramped or overlapping layout.

Normal flow
3

You apply clear

Set clear: left, right, or both on the element that should start below floats.

CSS rule
=

Clean layout below floats

The cleared element moves down past the specified floats, preventing overlap and restoring predictable flow.

Universal Browser Support

The clear property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It has wide compatibility and can be used reliably in web development.

Baseline · All browsers

Reliable float clearing everywhere

clear has been supported since the early days of CSS and works consistently across browsers.

99% Global browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions
Full support
Opera All modern versions
Full support
clear property 99% supported

Bottom line: Use clear with confidence. Logical values inline-start and inline-end are supported in modern browsers for internationalized layouts.

Conclusion

The clear property is an essential tool for managing the layout of elements in the presence of floating content. By using this property, you can control the flow of elements and prevent unwanted overlap or misalignment caused by floating elements.

Understanding and utilizing clear effectively helps you create more precise and visually appealing layouts — especially when working with float-based designs or maintaining legacy code.

💡 Best Practices

✅ Do

  • Use clear: both for footers and full-width sections below floats
  • Pair clear with floats when building classic column layouts
  • Use logical values (inline-start, inline-end) for RTL-aware layouts
  • Apply clearfix helpers when a parent must contain floated children
  • Prefer Flexbox or Grid for new layout projects when possible

❌ Don’t

  • Forget to clear floats before a footer or major section break
  • Confuse clear with the cursor or overflow properties
  • Overuse floats in new projects when Flexbox or Grid is simpler
  • Assume clear: left also clears right floats — use both when needed
  • Leave floated containers without a clearing strategy (collapsed height issues)

Key Takeaways

Knowledge Unlocked

Five things to remember about clear

Use these points when fixing float layout issues.

5
Core concepts
02

none Default

No clearing unless set.

Default
03

left / right / both

Pick which side to clear.

Values
📝 04

Works with float

Companion to float.

Context
🛸 05

Universal support

Works everywhere.

Browser

❓ Frequently Asked Questions

clear moves an element below preceding floated elements. It prevents the element from sitting beside floats and instead starts on a new line below them.
The initial value is none. With none, the element does not clear past floating elements unless you set left, right, both, inline-start, or inline-end.
float pulls an element out of normal flow so content wraps around it. clear is applied to a later element to stop it from wrapping beside those floats.
Use clear: both when you want an element to drop below all left and right floats above it. It is common for footers, section breaks, and clearfix helpers.
Modern layouts often use Flexbox or Grid instead of floats. clear remains important for understanding float-based layouts and for maintaining older code that still uses floats.

Practice in the Live Editor

Open the HTML editor, add floated boxes, and test clear: both on a footer block.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful