{"id":14027,"date":"2011-09-05T20:25:32","date_gmt":"2011-09-06T03:25:32","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14027"},"modified":"2022-09-15T16:07:54","modified_gmt":"2022-09-15T23:07:54","slug":"clear","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/c\/clear\/","title":{"rendered":"clear"},"content":{"rendered":"\n

The clear<\/code> property is directly related to floats<\/a>. If the element can fit horizontally in the space next to another element which is floated, it will. Unless you apply clear<\/code> to that element in the same direction as the float. Then the element will move down below the floated element.<\/p>\n\n\n\n

Here’s a simple example of a layout constructed with floats, which could be problematic for the footer:<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

But by clearing the footer element, the layout snaps into place:<\/p>\n\n\n\n

#footer {\n   clear: both;\n}<\/code><\/pre>\n\n\n\n
\"\"<\/figure>\n\n\n\n

In this case, clear: both; was used to ensure the footer clears past elements that are floated in either direction. But you can also clear either left<\/code> or right<\/code> in which case the element will move below elements that are floated that direction, but not the other.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

A common way to clear floats is to apply a pseudo-element to a container element which clears the float. Learn more about that here.<\/a><\/p>\n\n\n

Other Resources<\/h3>\n\n\n