What is the correct way to add caption to an image using html5

Bradz picture Bradz · May 17, 2013 · Viewed 22.6k times · Source

I am trying to work out the correct way to display a caption with an image, something like here makes sense jfiddle link but i am also looking at figure and figcaption which appears to serve the purpose better and I prefer ie:

<figure>
<img src="/animage.jpg" alt="an image">
<figcaption>This is the caption</figcaption>
</figure>

I am building a template for a blog news post so does either way matter or is there a correct use for figcaption that im missing?

Answer

Duncan Beattie picture Duncan Beattie · May 17, 2013

I would use the <figure> method as it has more semantic meaning than the div / span example.

http://jsfiddle.net/duncan/KYTWS/

related, although about blockquotes, http://alistapart.com/blog/post/more-thoughts-about-blockquotes-than-are-strictly-required