Course contentsShow
← Web Development
Lesson 239 of 2,9824. CSS Layout FoundationsFree lesson

The Clear Property

Using clear to control element positioning relative to floated elements and prevent unwanted wrapping.

The Clear Property

What You'll Learn

You'll learn how to use the clear property to control where elements can appear around floated elements, preventing them from wrapping unexpectedly.

Understanding Clear

When you float elements, other content flows around them. But sometimes you don't want that wrapping behavior — you want an element to start below any floated elements instead of sitting beside them. That's exactly what clear does.

Think of floated elements like furniture pushed against the walls of a room. The clear property is like telling someone, "Don't stand next to that furniture — move down until you find clear floor space."

How Clear Works

The clear property takes four values:

  • clear: left — Element moves below any left-floated elements
  • clear: right — Element moves below any right-floated elements
  • clear: both — Element moves below all floated elements (left or right)
  • clear: none — Default; allows wrapping around floats
.float-left {
  float: left;
  width: 200px;
}

.no-wrap {
  clear: left; /* This element won't wrap beside left floats */
}

.safe-section {
  clear: both; /* Moves below ALL floated elements */
}

Common Use Case

You'll often use clear: both on elements like section headers or footers to ensure they always start on a "fresh line" after floated content like images or sidebar widgets.

footer {
  clear: both; /* Footer always appears below floated content */
}

Key Takeaway: The clear property forces an element to move below floated elements rather than wrapping beside them, giving you precise control over layout flow around floats.