HTML <caption> Tag

Beginner
6 min read
Updated: Oct 2026
4 examples
Live preview

Definition and Usage

The <caption> element specifies the title (or caption) of a <table>. It gives the table an accessible name so users can decide relevance before reading every cell.

Put it as the first child of <table>. Write a short, descriptive title — not vague labels like “Table 1.” Style position with CSS caption-side, not HTML align.

Baseline · Widely available.

Not deprecated as an element. Stable across browsers since about July 2015 (and much earlier in practice).

Deprecated attribute.

Do not use align on <caption>. Use CSS caption-side and text-align instead.

HTML Syntax

syntax.html
<table> <caption>title text</caption> … </table>

<caption> is allowed only as the first descendant of <table>. One caption per table. The end tag may be omitted in HTML if nothing awkward follows, but keeping both tags is clearer for learners.

Attributes

<caption> has no modern element-specific attributes — only globals, plus one obsolete attribute:

AttributeDescriptionTry it
alignDeprecated. Was left, top, right, or bottom. Use CSS caption-side / text-align.Avoid

Global Attributes

The <caption> tag also supports the Global Attributes in HTML.

Live Preview

Change the caption text and caption-side, then see a real table update.

A real <caption> inside <table>. Position comes from CSS, not align.

Table
Employee contact list
NameRole
AlexDesigner
SamDeveloper

caption-side: top

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic Table Caption

Place <caption> first inside <table>, then add rows.

HTML
<table>
  <caption>Employee contact list</caption>
  <tr>
    <th scope="col">Name</th>
    <th scope="col">Age</th>
  </tr>
  <tr>
    <td>John</td>
    <td>25</td>
  </tr>
  <tr>
    <td>Mary</td>
    <td>30</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Open <table>. The caption belongs inside this parent only.
  2. Add <caption> first with a clear title for the data.
  3. Add header and data rows with <th> / <td>.
  4. Close the table. Browsers show the caption above by default.

Example 2 — Caption with thead and tbody

Keep caption first, then structure the table with <thead> and <tbody>.

HTML
<table>
  <caption>User login email addresses</caption>
  <thead>
    <tr>
      <th scope="col">Login</th>
      <th scope="col">Email</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>user1</td>
      <td>[email protected]</td>
    </tr>
    <tr>
      <td>user2</td>
      <td>[email protected]</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Caption stays first — before thead or tbody.
  2. Group headers in <thead> for a clear column title row.
  3. Put data rows in <tbody>.
  4. Use scope="col" on header cells so assistive tech maps columns correctly.

Example 3 — Caption Below the Table

Move the visual position with CSS caption-side: bottom (not align).

HTML
<style>
  caption { caption-side: bottom; }
</style>

<table>
  <caption>Monthly rainfall (mm)</caption>
  <tr>
    <th scope="col">Month</th>
    <th scope="col">Rain</th>
  </tr>
  <tr>
    <td>Jan</td>
    <td>42</td>
  </tr>
  <tr>
    <td>Feb</td>
    <td>38</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Keep caption first in HTML — document order does not change.
  2. Set caption-side: bottom in CSS to render under the table.
  3. Do not use align="bottom" — that attribute is deprecated.
  4. Optionally add text-align for left/center/right text alignment.

Example 4 — Write a Clear Caption

Describe what the table is about so scanners and screen reader users get context fast.

HTML
<table>
  <caption>Average temperature (°C) by city, 2025</caption>
  <thead>
    <tr>
      <th scope="col">City</th>
      <th scope="col">Avg °C</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Berlin</td>
      <td>11</td>
    </tr>
    <tr>
      <td>Tokyo</td>
      <td>16</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Name the dataset in the caption (what, units, time range when useful).
  2. Avoid empty or vague titles like “Data” or “Table.”
  3. Keep it short — one clear sentence or phrase is enough.
  4. Let headers name columns; the caption names the whole table.

Edge Cases & Pitfalls

Most caption bugs are wrong placement, deprecated align, or weak wording.

order

Must be the first child of table

Do not put <caption> after <thead> or rows. Invalid order breaks the accessibility mapping.

count

Only one caption per table

Extra captions are not valid. Use one clear title for the whole table.

css

Table background skips the caption

background-color on table does not fill caption. Style caption if you need a matching backdrop.

figure

Figure wrapping only a table

If <figure> contains only a table, caption the figure with <figcaption> rather than relying on a nested table caption alone (MDN).

deprecated

Skip align

Use caption-side and text-align. The HTML align attribute on caption is obsolete.

Browser Support

The <caption> element is core HTML for tables in every browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<caption>

Widely available since about July 2015 (and long before as HTML tables). Chrome, Firefox, Safari, Edge, and Opera all support table captions. Prefer CSS caption-side over the deprecated align attribute.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
<caption> Widely supported

Bottom line: Safe to use on every data table that needs a title. Avoid align; style with CSS caption-side and text-align.

Key Takeaways

  • Role: <caption> titles a <table> for people and assistive tech.
  • Placement: first child of <table>; only one per table.
  • Text: describe the dataset; avoid vague labels like “Table 1.”
  • Position: use CSS caption-side, never deprecated align.

One line: a good <caption> is first in the table and names what the data is about.

Default CSS Settings

Typical user-agent styling for captions (exact rules vary by browser):

default.css
caption {
  display: table-caption;
  text-align: center;
}

Default visual side is the top of the table. Override with caption-side: bottom and adjust text-align / font weight as needed.

Frequently Asked Questions

The caption element gives a table an accessible name or description — a title that sighted users see and screen readers announce with the table.
If present, caption must be the first child of table — before thead, tbody, tfoot, tr, colgroup, or col. Only one caption per table.
No. align is deprecated. Use CSS caption-side (top or bottom) and text-align instead.
caption titles a table. figcaption captions a figure. If a figure only wraps a table, prefer figcaption on the figure rather than nesting caption alone as the figure’s only content (MDN guidance).
No. background-color on table does not paint the caption. Style caption separately if you want matching backgrounds.
Data tables that convey information should have a clear caption (or another accessible name). Decorative layout tables are outdated; use CSS layout instead.

Next: center

See why the obsolete center element is replaced by CSS text-align.

center tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful