Stop a DIV from collapsing when you float elements inside it.

Stop a DIV from collapsing when you float elements inside it.

Last updated:

Floated divs (float:right; or float:left;) don't contribute the the parent container's height, so if you have a parent div with a child div inside, the parent div will collapse (i.e. have it's height down to zero) if you float the child div left or right.

A way to circumvent that is to:

add overflow:auto; to the parent container.