CSS

CSS

🎯 CSS clear Property

The clear CSS property controls how an element behaves in relation to floated elements in a layout.

It is used to prevent elements from sitting next to floated items and forces them to move below left, right, or both sides of floated elements.

🔹 Why Use clear?

The clear property is essential when building layouts with float. It helps fix layout overlap issues and ensures proper element positioning.

  • Prevents layout overlapping
  • Fixes float-related positioning issues
  • Improves layout structure
  • Useful in legacy float-based designs

🧩 clear Values

1️⃣ none (Default)

The element does not clear any floats and stays in normal flow.

CSS

div {
    clear: none;
}
                

2️⃣ left

The element moves below any left-floated elements.

CSS

div {
    clear: left;
}
                

3️⃣ right

The element moves below any right-floated elements.

CSS

div {
    clear: right;
}
                

4️⃣ both

The element clears both left and right floated elements and moves below them.

CSS

div {
    clear: both;
}
                

5️⃣ initial

Resets the property to its default value (none).

6️⃣ inherit

Inherits the clear value from the parent element.

📌 Quick Summary

  • 🧠 Overview

  • none → no clearing (default behavior)
  • left → clears left-floated elements
  • right → clears right-floated elements
  • both → clears both left and right floats
  • initial → resets to default value