Figures & Image Maps

A <figure> groups an image, chart, code sample or quotation with its caption, so they're understood as one unit. Image maps make different areas of a single image clickable. This lesson covers both.

Figure and figcaption

Try it yourself
Result

<figure> represents self-contained content that's referred to from the main text but could be moved elsewhere — to a sidebar or an appendix — without breaking the flow. The optional <figcaption> must be the first or last child.

Alt text vs caption

They do different jobs, and you usually need both:

  • alt replaces the image for people who can't see it — it describes what the image shows.
  • figcaption is visible to everyone and adds context — credit, date, source, explanation.

Avoid repeating the caption word-for-word in the alt text, since screen-reader users would hear it twice.

Figures aren't only for images

Try it yourself
Result

Code listings, tables, charts, video clips and quotations all fit. Several images can share one figure, like a before-and-after comparison.

Image maps

An image map defines clickable regions on an image. The <map> contains <area> elements with shapes and coordinates, and the image links to it with usemap:

Try it yourself
Result
shapecoords
rectx1,y1,x2,y2 — top-left and bottom-right corners
circlex,y,radius
polyx1,y1,x2,y2,x3,y3,… — the corners of a polygon
defaultThe whole image not covered by other areas

When areas overlap, the first one listed wins — which is why the centre circle above should really be listed first. Each <area> needs alt text, since it's a link.

Limitations: image map coordinates are in pixels of the image's original size, so they don't adapt when CSS scales the image responsively, and the clickable areas aren't visible. For interactive diagrams, an inline SVG with links (lesson 41) or positioned HTML buttons over the image usually works better today.

Try it yourself

Try it yourself
Result