Table with Caption Template
Properly title your data table with the semantic caption
element for improved accessibility and context.
A caption acts as the official heading for your table, clearly describing its contents to all users, including those using assistive technologies.

About the Table Caption
While you can always put a heading element (like h3
) above a table, the most semantically correct way to title a table is with the caption
tag. This element must be the first child of the table
element. Using it programmatically links the title directly to the table it describes. This template provides a clean example of its implementation and styling.
Key Features:
- Semantically Correct: Uses the HTML standard for titling tables, which is better than a generic heading tag.
- Improved Accessibility: Screen readers announce the caption when they encounter a table, giving users with visual impairments immediate context about the data.
- Easy Styling: The caption can be styled with CSS like any other text element. The CSS property
caption-side
can also move it to thebottom
. - Clear Context: A caption ensures there's no ambiguity about what the table data represents.
Ideal Use Cases:
- Scientific or academic reports where figures and tables must be properly labeled.
- Financial statements that require clear titling (e.g., "Q3 2024 Earnings Report").
- Any document or webpage where multiple tables appear, and each needs a distinct title.
- Whenever you need to be compliant with accessibility standards like WCAG.
Dependencies:
None. This template uses only pure HTML and CSS.
Code
Here's the full code for the table with a caption: