Centreing a DIV without setting its width

Is it possible to centre a DIV horizontally on the page, without actually setting a width for that DIV. The DIVs content is generated at runtime, so the width is unknown.
Date Created: 29th September 2006
Date Modified: 29th September 2006
Home > CSS > Centreing a DIV with no width set

Trying to answer WebmasterWorld CSS Forum:
http://www.webmasterworld.com/css/3101102.htm

Also see http://www.webmasterworld.com/forum83/5929.htm

A 2px border (blue in this case) is required around the image and the caption. Hhhmmm, can't seem to quite do it!

Image Caption

Image Caption

Works OK in IE6 and Opera, FF displays caption next to image, even after <br>... using <span> tags and display:inline-block; (display:-moz-inline-box; for FF)

Image Caption

Some caption

[Home]