When should I use: hidden overflow for <div>?
Suppose I have this HTML structure:
<div class="a">
<div class="floated-left">...</div>
<div class="floated-left">...</div>
</div>
I noticed that if I do not set overflow:hiddento .a, then it <div class="a">does not occupy any vertical size. For example, if I set my background to red, it does not appear at all. Examining it with FireBug shows that it is there, but almost has no vertical size.
To fix this, I found that I need to install overflow:hiddenin .a. Then the first <div>looks through all its contents.
Here is a real example:
<html>
<head>
<style>
.a { background-color: red; }
.b { background-color: red; overflow: hidden }
.floated-left { float: left; width: 100px; height: 100px; background-color: blue; }
</style>
</head>
<body>
<p>div with class a, that doesn't overflow:hidden:</p>
<div class="a">
<div class="floated-left">Hi,</div>
<div class="floated-left">Mom!</div>
</div>
<div style="clear:both"></div>
<p>div with class b, that does overflow:hidden:</p>
<div class="b">
<div class="floated-left">Hi,</div>
<div class="floated-left">Dad!</div>
</div>
</body>
</html>
Note that it Hi, Mom!does not receive a red background (without overflow: hidden), but Hi, Dad!receives a red background (has overflow: hidden).
Can anyone explain this behavior?
Here is a screenshot of the example:

, .
+3
4