Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

figcaption — a caption for figure content

The `figcaption` element captions the contents of `figure`. It must be a direct child, placed at the beginning or the end.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<figure>
  <!-- Figure content -->
  <figcaption>Caption text</figcaption>
</figure>

figcaption represents a caption or legend for the remaining contents of its parent figure element. It is not limited to illustrations: it can also describe a diagram or code listing. The caption can include source information.

A figure may contain at most one direct figcaption element, as its first or last child. The caption is optional. Do not place it between parts of the content being described or inside an extra container instead of directly inside figure.

figcaption accepts flow content, such as text, links, and paragraphs. It supports global attributes and uses the HTMLElement DOM interface. Both its opening and closing tags are required. In the example, the caption describes an equation presented as a listing; it is not part of the code itself.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Caption example</title>
</head>
<body>
  <figure>
    <pre><code>2 + 3 = 5</code></pre>
    <figcaption>Listing 1. An addition equation.</figcaption>
  </figure>
</body>
</html>

Result

2 + 3 = 5
Listing 1. An addition equation.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources