Jump to content


This topic is now archived and is closed to further replies.


general question about clear:both

Recommended Posts

Hi all

Anyone have any idea why some browsers create a huge gap underneath floats when using either <div> or <br /> styled with clear:both, and how to avoid it? it normally happens within a DIV that has a margin of, say, 200px to allow for a left-floated menu that sits outside of it. when i remove the menu, and the margin, the problem goes away.


Share this post

Link to post
Share on other sites
If you use margin: 200px then its going to add a 200px margin on all sides and thus you get a gap when your use clear:both. Just apply the margin/padding to the side you want it on:
margin-left: 200px

Or float the left and right elements to the left then you don't need to worry about adding margins to position the element on the right. The elements will but-up-against each other.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.