Visit me elsewhere:

css float elements, div or whatever

If you didn’t know, instead of using a clear:both there’s a really simple and easy way to make a container (like div) have the height of it’s floating children.

Just give it the css attribute overflow:hidden;

Yes, that’s all.


<div style="background-color:#644;">parent<br /> <div style="float:left; background-color:#446; padding:20px; margin:10px 0px 0px 10px;">float:left;</div><br /> </div>

parent

float:left;

<div style="background-color:#644; overflow:hidden;">parent<br /> <div style="float:left; background-color:#446; padding:20px; margin:10px 0px 0px 10px;">float:left;</div><br /> </div>

parent

float:left;