Containing floats in block elements

I just wanted to bookmark a really useful page about how to make block elements in CSS expand to contain floated elements.

There are a couple of suggested ways to deal with this on the page but the one I needed today was adding an element to the end of the float that has the style

  1. <div id="outer">
  2.     <img src="elephant.jpg" style="float: left"/>
  3.     <div style="clear: left;"></div>
  4. </div>
Posted on 25 Jan 06 by Helen Emerson (last updated on 25 Jan 06).
Filed under CSS