Scaryguy's is answer pretty much correct. But the outer div should have overflow: hidden
for the conteiner to work properly.
See this example: http://jsfiddle.net/QCf4U/

The code in the example has all the red boxes with float: left
. And there are 4 blue divs that contain (the first 2 blue divs are stuck together on the top):
- No clear and no float, and has 3 red divs inside
- No clear and no float, and has 3 red divs inside
- Has
clear: left
, and 5 red divs inside
- Has
overflow: hidden
, and 5 red divs inside
Notice that without clear nor float nor overflow: hidden
on the container, your red divs on container 1 and 2 will be next to each other (not following the container).
You can see that for the container blue div to get its correct vertical size you have to use overflow: hidden
(or maybe float
there too).