HTML <caption> Element

The <caption> element provides a caption or title for a <table>. It helps describe the purpose of the table and gives users useful context before they read the table's data.

Syntax

<table>
  <caption>Table Caption</caption>
  ...
</table>

The <caption> element must be the first child of its parent <table> element. It may contain flow content.

Attributes

The <caption> element supports the global HTML attributes. It does not have any current element-specific attributes.

The older align attribute is deprecated and should not be used. CSS properties such as caption-side and text-align should be used to control the caption's position and alignment.

Example

The following example gives a table a caption that describes its contents:

<table>
  <caption>Monthly Website Visitors</caption>
  <thead>
    <tr>
      <th>Month</th>
      <th>Visitors</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>January</td>
      <td>1,250</td>
    </tr>
    <tr>
      <td>February</td>
      <td>1,480</td>
    </tr>
  </tbody>
</table>

The caption identifies what the table represents before the reader begins examining its rows and columns.

Try It Yourself

Edit the caption text to see how it provides a visible title for the table.

Play in Editor

Usage Notes

If a table includes a <caption>, it must appear as the first child of the <table> element, before elements such as <colgroup>, <thead>, <tbody>, or table rows.

A caption should briefly describe the table as a whole rather than repeat individual column headings or cell content.

Browsers normally display table captions above the table. CSS can change the placement using the caption-side property.

When a table is the only content of a <figure>, a <figcaption> may be more appropriate for captioning the figure as a whole instead of using a table caption.

Accessibility

A meaningful <caption> can help users quickly understand the purpose of a table before reading its contents. This is especially useful for people using screen readers, who can determine whether the table is relevant before navigating through its cells.

Use a clear, concise caption that describes the table's overall subject. Do not rely only on surrounding text when the table itself would benefit from an explicit caption.

Browser Support

Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.

For detailed browser compatibility information, see Can I Use: HTML <caption> Element .

<table> - Represents tabular data and can contain a <caption> as its first child.

<figcaption> - Provides a caption or legend for the contents of a <figure>.

<th> - Defines header cells that identify rows or columns within a table.

Specifications

HTML Living Standard: The <caption> Element