I'd try to use display: inline-block;
to style the elements containing each image.
Example of HTML code for one container:
<style>
.figure {
display: inline-block;
}
</style>
<div class="figure">
<img src="littlepony.jpg" alt="My cute little pony" width="13" height="37" />
</div>
Now there a few pitfalls using this with IE6, IE7 and Firefox 2:
- IE 6 and 7 will only style inline elements that have hasLayout triggered, I mean you'll see inline-block behavior if you do this:
<!--[if lte IE 7]>
.figure {
display: inline;
zoom: 1; /* triggering hasLayout */
}
<![endif]-->
- Firefox 2 doesn't understand
display: inline-block;
so you'll have to precede the latter by another display instruction:
.figure {
display: -moz-inline-stack;
display: inline-block;
}
- now Firefox 2 is going to annoy you a bit. First, you must have only one child element in your
.figure
element, otherwise the children would ... stack. So if you have a legend under your image, insert a div between div.figure and img+p
<div>
<img src="littlepony.jpg" alt="Photo of my cute little pony" width="13" height="37" />
<p>Second child of .figure>div and not .figure</div>
</div>
</div>
Second (still only in Fx2), you'll notice from time to time that you can't anymore neither select text inside the -moz-inline-stack'ed element nor click on links it could contain. The fix is to position the added div relatively:
.figure div {
position: relative;
}
Of course the conditional comment for IE6/7 must occur after regular CSS, otherwise it'll be of little help.
And finally, if no elegant solution works for you, use a TABLE. A simple table with only td and no th. If it occurs that:
- IE6 and 7 don't like
display: table-sth
- your CMS causes problems to what would otherwise work fine on another site
- Firefox 3 support for
inline-block
is of no help
than yes it's better for everybody that you use a table and no half-solution causing problems to half your users ;)