Quick question!
Does putting a “clear” element INSIDE a floated div do anything?
Like:
<div style="float: right">
blah blah
<div style="clear: right"></div>
</div>
Somewhere somehow I got the impression that this helps the div expand to contain the content inside of it. What does it actually do? Anything?
Thanks!
An element which contains nothing but floats will collapse in height, because the floated elements are no longer in the normal document flow. In such a case, clearing after the floats will allow the containing element to retain its height.
Note that there are other ways to clear than using clearing elements, such as adding
overflow:hidden;to the container styles.