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

caption

Provides a title or description for a table. Vanilla Breeze styles captions with start-aligned text, muted color, and medium font weight to clearly label tabular data without competing with the data itself.

Description

The <caption> element must be the first child of a <table>. It provides a programmatic association between the table and its description, which screen readers announce when a user navigates to the table.

Name computation: the caption becomes the table's accessible name. An aria-labelledby or aria-label on the <table> overrides it (the caption is then ignored for naming), so use one or the other.

Content model: flow content, but no <table> descendants. Headings, paragraphs and inline elements are all allowed.

Vanilla Breeze styles captions with text-align: start (RTL-aware), font-weight: 500 for medium emphasis, and var(--color-text-muted) so the label does not compete visually with the data. Padding matches the cell padding (var(--size-s) var(--size-m)) to keep alignment consistent with table content.

When to Use

  • Every data table: data tables benefit from a caption (or another accessible name)
  • Table identification: when multiple tables appear on the same page
  • Context setting: to explain what data the table contains
  • Time-sensitive data: to indicate the date or period the data represents

When Not Required

  • Tables with adjacent headings: if a heading immediately precedes the table, you can use aria-labelledby to link them instead
  • Non-tabular content: for image descriptions, use <figcaption> inside a <figure>

Basic Example

The demo below shows a complete table with a caption as its first child, followed by <thead>, <tbody>, and <tfoot>. Note how the caption aligns with the table content.

Rich Captions

Captions can contain inline elements like <small> for secondary information such as data sources or date ranges.

Caption Position

Captions render above the table by default. Use caption-side: bottom to place one underneath; the caption stays first in the source, so it is still announced first.

VB Integrations

  • Numbered articles: inside article[data-numbered], every table caption is prefixed with “Table N:” automatically. Do not type the number yourself.
  • CSS charts: in a .vb-chart table (see <chart-wc>), the caption is restyled as the chart title, stronger and in the body text colour.

Alternative: aria-labelledby

When a visible heading immediately precedes the table and serves as its label, you can use aria-labelledby instead of duplicating the text in a caption.

CSS Reference

The styles Vanilla Breeze applies to caption elements.

Property Value Purpose
padding var(--size-s) var(--size-m) Matches cell padding for visual alignment
text-align start Left-aligned in LTR, right-aligned in RTL
font-weight 500 Medium weight for subtle emphasis
color var(--color-text-muted) Muted to differentiate from data content

Accessibility

  • Screen reader announcement: when a user navigates to a table, the caption is announced first, providing immediate context
  • Be descriptive: write captions that explain what data the table contains, not just "Table 1"
  • Include temporal context: if data is time-sensitive, include the relevant period
  • WCAG: a caption is not required. Using <caption> is a sufficient technique (H39) for Success Criterion 1.3.1 Info and Relationships, because it ties the table to its description programmatically

Related

  • <table> - parent container (caption must be its first child)
  • <thead> - header group that follows the caption
  • <figcaption> - similar purpose for figures and images (compare: <caption> is for tables, <figcaption> is for figures)
  • <summary> - similar "label" role for <details> disclosure widgets
↑