As a web developer I frequently will have two floated (child) divs inside of another (parent) div. Actually I do this all day long.
<style type="text/css">
#left {float:left;}
#right {float:right;}
</style>
<div id="parent">
<div id="left" class="child"> </div>
<div id="right" class="child"> </div>
</div>
This doesn't work without an extra bit of css/html because the parent doesn't automatically grow to fit floated children. There are two popular ways of overcoming that:
1) Add overflow:hidden
to the parent's css.
2) Add a 3rd "clearing" child <br style="clear:both;" />
.
I know there's a few other similar questions about such things, but my question is:
Which method is better and why? What are the pros and cons of each?