← Back to HTML & CSS, page 7

html-css-0134 · Easy fresher

How do you mark up an image with a caption and a quotation correctly?

A figure wraps self-contained content such as an image, and figcaption gives it a visible caption. The caption does not replace alt text, which describes the image for people who cannot see it. A blockquote marks a long quotation, with the source named in visible text.

Full answer

Use figure for self-contained content that is referred to from the text and could move elsewhere without breaking the sense: an image, a chart, a code sample, a quote. figcaption gives it a caption, and it must be the first or the last child of the figure.

The figcaption also gives the figure an accessible name in many browsers, so assistive tools can announce "figure, Students at the gate".

A caption is not the same as alt text.

  • alt replaces the image for people who cannot see it. It describes what the image shows or what it is for.
  • figcaption is visible text for everyone. It adds context, such as a source or a date. If the caption already describes the image fully, the alt can be short, but it should not be left out unless the image is decorative. Do not repeat the same sentence in both, because screen reader users hear it twice.

For quotes:

  • blockquote holds a longer quotation taken from another source. The optional cite attribute gives the address of the source. It is not shown by browsers, so name the source in visible text as well.
  • Put the attribution in a figcaption inside a figure around the blockquote, with the source in a cite element, which is used for the title of the work.
  • q is for a short quote inside a sentence.

Do not use blockquote just to indent text, since it carries the meaning of a quotation.

Each figure groups its content with its caption. The image keeps a short, useful alt, and the quote gets its source in a visible caption. The default style of a figure adds side margins, which you can reset in CSS.

Check with a screen reader that the caption and the alt text do not repeat each other.

html
<figure id="f1">
  <img src="/img/gate.jpg" alt="Students walking through a stone gate" width="300" height="200">
  <figcaption>Students at the gate, 2026.</figcaption>
</figure>
<figure id="f2">
  <blockquote cite="https://example.com/talk"><p>Make it work, then make it fast.</p></blockquote>
  <figcaption>Speaker name, <cite>Talk title</cite></figcaption>
</figure>

Run in Chrome 156 (headless) as a page; the snippet is wrapped in a minimal HTML document with doctype, charset and viewport meta tag. Two full runs gave identical results, and the measured values in the answer come from them.

Key points

  • figure groups self-contained content; figcaption is its caption.
  • figcaption must be the first or last child.
  • alt and figcaption have different jobs.
  • blockquote is for quotations, not indentation.
  • Name the source in visible text.

Common mistakes

  • Using figure for every image, even when it is just a decoration or a part of the page layout.
  • Copying the caption into the alt attribute.
  • Using blockquote only to indent text.

Follow-ups

  • Where can figcaption go inside a figure?
  • What does the cite attribute on blockquote do?

Tips

  • Explain figure as a self-contained unit with an optional caption.
  • State the difference between alt and figcaption.