Here is a test file.
Resize the window to be wide enough to hold all four boxes. Notice the container is no wider than the boxes, as intended.
Resize the window to be small enough that the boxes are on more than one line. Notice the container is the full width of the page (this is unintended).
Why? Is it possible to prevent this in a way that does not depend on the size of the boxes?
(Seen on Firefox 3.5 and Chrome 4.0.221.8. If a solution doesn't work in IE6, that's fine.)
CSS 2.1 section 10.3.5 Floating, non-replaced elements (http://www.w3.org/TR/CSS21/visudet.html#float-width) says that:
width = min(max(preferred minimum width, available width), preferred width)
This is completely sane for cases of text wrapping (imagine if the width changed depending on how close the line ends got to the edge of the available space) but not what you want here. I can't see a way to avoid this, though.