Forum How do I...?

Aligning two elements: Figure and caption

srobertjames
Is there a way to align two elements?

Specifically, I'd like to align an image and it's caption.

(While I'm asking: how do I tell the caption to autonumber the image, eg Fig 2.3, and then reference it elsewhere?)

Thank you.
mikeday
There are text-align and vertical-align properties, it really depends what kind of alignment you are trying to achieve. Automatic numbering can be done using counters and cross-references.
srobertjames
mikeday wrote:
There are text-align and vertical-align properties, it really depends what kind of alignment you are trying to achieve.


Thank you.

I'd like to align the left edges of the image and its caption, and put the caption a fixed distance below the image.
mikeday
If you were using this HTML markup for images and captions:
<div class="image"><img src="myimage.jpg"/></div>
<div class="caption">This is a caption!</div>

Then they would be left aligned by default, and you could add vertical spacing between them by adding bottom margin to the image and/or top margin to the caption.