I try to do the following design:

There are some quantity of blocks. The quantity is different each time I draw the page.
They all included in one outer block with width in %.

Each block includes:
- one image (always the same, width="40px")
- one string (there are <=15 characters, every character could be different); the length of the line could be more than the width of the image above it

I need:
1. All blocks should be the same width.
2. Blocks should occupy all empty place within outer block line by line, i.e. if, for example, 3 blocks are enough to full the first line, the 4d block should be right under 1st, 5th - under 2nd and so on.
By eye blocks should become arranged like in a table.

How can I do that?

Thanks in advance.