Home > Web development > Using clear in CSS

Using clear in CSS

July 15th, 2008

If you ever use floats, and then tried to add content to a container that's not floated, you may have experienced the same issues that many have. The solution is far simpler than expected

 
.clear { clear: both; }

This forces any item with a class of clear to be clear of floats on the left and right, which are - by chance - the other two options to clear; left and right. So after floating elements left and right, you should add a to force content below.

Popularity: 14% [?]

Web development

  1. No comments yet.
  1. No trackbacks yet.