I have a gallery of thumbnails in a div floated left so they all sit next to each other. When the amount of thumbnails don't equate to a full line I'd like the container div's coloured background to show.
If you view link you can see it as I'd like - the bluey colour filling the last line - I have done this by specifying an exact height on the container div - how do I make this automatic?
When clearing floats, be sure to place the clearing element within the parent element. In your case, take
<br style="clear:left;" /> and move it into #gallery, as opposed to after it. Otherwise, the break tag is trying to clear the float of the parent element itself (of which it doesn't have).