Nearby lessons

19 of 19

🧹 CSS Clear Property

📌 What is CSS Clear Property?

The clear CSS property is used to control the behavior of elements following floated elements.

  • left – Prevents the element from being beside left-floated elements.
  • right – Prevents the element from being beside right-floated elements.
  • both – Moves the element below any floated elements on either side.
  • none – Default value; element does not clear any floats.

🔹 clear: left

The element is pushed below any left-floated elements.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

🔹 clear: right

The element is pushed below any right-floated elements.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

🔹 clear: both

The element is pushed below both left- and right-floated elements.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

💡 Clear Property Best Practices

  • ✅ Use overflow: auto or display: flow-root on containers to clear internal floats (clearfix technique).
  • 📏 Use clear: left, right, or both only when necessary for layout clarity.
  • 🧼 Prefer modern layout techniques like Flexbox or Grid over float + clear for new designs.
  • 📚 Document float/clear usage in complex layouts for team understanding.
  • ⚠️ Use clear on block elements, not inline elements.

🧠 Test Your Knowledge

5 Questions

Progress: 0 / 5
Keep Going!Course Complete!