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…
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
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.
Table with caption element
12345678910111213
<table><caption>Quarterly Sales Report</caption><thead><tr><thscope="col">Product</th><thscope="col"data-numeric>Q1</th><thscope="col"data-numeric>Q2</th></tr></thead><tbody><!-- Table data --></tbody></table>
Rich Captions
Captions can contain inline elements like <small> for secondary information such as data sources or date ranges.
Caption with secondary description
12345678
<table><caption> Quarterly Sales Report<br /><small>Data from January - March 2024</small></caption><!-- thead, tbody... --></table>
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.
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.
Table labelled by a heading
1234
<h3id="sales-heading">Monthly Sales Data</h3><tablearia-labelledby="sales-heading"><!-- Table content without caption --></table>
CSS Reference
The styles Vanilla Breeze applies to caption elements.
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)