Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

figcaption

The figcaption element provides a caption or legend for the content of its parent figure element.

Description

The <figcaption> element represents a caption or legend describing the contents of its parent <figure> element. It can appear as the first or last child of the figure, and there can only be one figcaption per figure.

Vanilla Breeze styles figcaption with muted text color and smaller font size, with variants for alignment and visibility.

When to Use

  • Image descriptions - Explain what an image shows or why it's relevant
  • Photo credits - Attribution for photographers or image sources
  • Figure numbering - "Figure 1:", "Chart 2:", etc.
  • Code file names - Identify the source file for code examples
  • Quote attribution - Identify the source of a quotation
  • Data sources - Credit the source of chart or graph data

Placement

Figcaption can appear at the beginning or end of a figure. VB adapts the spacing to the position: a trailing caption gets space above it, a leading caption gets space below it (and .bordered / .code figures move their divider and rounded corners to match).

Caption After Content (Default)

Caption Before Content

Variants

Alignment: default, .centered, .end

Captions are start-aligned by default (left in LTR). .centered centers them; .end aligns them to the inline end (right in LTR, left in RTL).

.hidden (Visually Hidden)

Keeps the caption in the accessibility tree — it still names the figure — without showing it. The declarations are identical to the .visually-hidden utility, so class="visually-hidden" works the same way.

Caption Content

Figcaption accepts flow content: numbering, links, citations, and even multiple paragraphs.

For automatic “Figure N:” prefixes, put the figures inside <article data-numbered> instead of typing the numbers.

Context-Specific Captions

In code figures the caption usually shows the filename; in quote figures it carries the attribution (with a leading dash); for media it can link to a transcript.

Accessibility

Role in Accessibility

A <figure> always has the figure role. Per HTML-AAM, its first <figcaption> child provides the figure's accessible name, so assistive technology can identify the figure by its caption when a user reaches it. Exactly how and when the caption is spoken depends on the screen reader and browser.

Alt Text vs Figcaption

These serve different purposes and shouldn't duplicate each other:

Attribute/Element Purpose Audience
alt Describes the image itself Screen reader users (replaces image)
<figcaption> Provides context about why the image is shown All users (supplements image)

Visually Hidden Captions

Use .hidden (or .visually-hidden) only when a meaningful figure needs a name but the visual design has no room for a caption. Decorative images don't belong in a <figure> at all — give them alt="" and leave them out of the accessibility tree.

Related

  • <figure> - Parent element that contains figcaption
  • <img> - Images that figcaptions describe
  • <blockquote> - Quotations that may have figcaption attribution

CSS Reference

Styles defined in /src/native-elements/figure/styles.css

Selector Properties
figcaption font-size: var(--font-size-s); color: var(--color-text-muted); margin-block-start: var(--size-s);
figcaption.centered text-align: center;
figcaption.end text-align: end;
figcaption.hidden Same declarations as .visually-hidden (position, 1px size, -1px margin, clip, nowrap, no padding/border), !important
figure > figcaption:first-child margin-block: 0 var(--size-s);
figure.bordered > figcaption margin-block-start; padding-block-start; border-block-start;
figure.code > figcaption margin-block: 0; padding; background; border-radius; font-family: mono;
figure.quote > figcaption font-style: normal; ::before adds em-dash;
↑