It's quite simple but totally unobvious. You have to understand exactly what
float: left means in this situation.
It's all explained in sectino 9.5.1 of the CSS reccomendation, particularly
rule 2:
"If the current box is left-floating, and there are any left-floating boxes
generated by elements earlier in the source document, then for each such
earlier box, either the left outer edge of the current box must be to the
right of the right outer edge of the earlier box, or its top must be lower
than the bottom of the earlier box."
Consider how those floated left containers (your class=select divs) are
layed out.
The first one (the slightly longer one) is easy as there are no prior
floated boxes, just float it left to the border of its container.
The second one is almost as easy, just float it left until it hits container
1.
Similarly for three and four.
Now, container 5 does not fit to the right of container 4 so the second part
of rule 2 comes into effect, its top must be below the earlier box,
container 4.So, drop it down to just below container 4.
But, it still needs to be floated left so it is, it is slid left until it
hits something, namely the right side of container 1 (which is protuding
down below 2, 3 and 4). It doesn't hit containers 2 and 3 because it is
already below their bottoms (refer again to the rule above). It doesn't
slide over to the left side of the outer container (as you might wish it
would) because, as per the above rule, it must be to the right of the prior
box (container 1) *before* we consider if it must be below that box
(container 1).
We proceed with containers 6 and 7 which go where you see them. Then
container 8, it can't fit to the right of 7 so it gets dropped down below
the bottom of 7, and then slid left until it hits something, the edge of its
container.
Temporarily switch borders on for those <div class=select>s (using firebug
perhaps) and you will see exactly what is happening.
Bottom line: If you wish to use this technique to lay out a rectangular grid
of things then you must make absolutely sure that each one of them is the
same height. this generally means images only, no text. You can't ensure
that somebody might not up their font size and cause a line wrap. I suppose
you could use white-space: nowrap to ensure no line wraps but then you are
faced with text that may escape out the right hand side of those containers.
If it were me I would simply put the whole lot in a table (probably a CSS
one) and be done with it. While this could be labled as "abusing tables for
layout" we *know* it will work, whereas we *know* your method will fail
under certain conditions (font size, amount of text). Fiddling with left
floated divs just doesn't work in your case.
and while I'd consider changing the color I
think she was aiming
for white on the greyish black. What color text do you think might
contrast better on that
dark grey?
My preference is very dark black on white.