<caption>, <colgroup> & <col> Tags in HTML

Quick facts

CategoryNone of their own — they are only allowed inside tables
Content model<caption>: flow content, but no tables. <colgroup>: zero or more <col> (or nothing if it has span). <col>: empty, it’s a void element
Tag omission<col> is void (no end tag). <caption> and <colgroup> end tags can be left out in some cases, but writing them is best practice
Permitted parents<caption>: a <table>, as its first child. <colgroup>: a <table>, after the caption and before any rows. <col>: a <colgroup>
DOM interfacesHTMLTableCaptionElement, HTMLTableColElement (<colgroup> and <col>)

Syntax

<table> <caption>Monthly sales</caption> <colgroup> <col> <col span="2" class="highlight"> </colgroup> ... </table>

Live example

Edit the code below and watch the preview update instantly.

index.html
Preview

Attributes

<colgroup> and <col>

AttributeDescription
spanHow many columns this element covers (default 1)

<caption>

AttributeDescription
—Only the global attributes apply. The old align attribute is obsolete; use the CSS caption-side property.

Common examples

A table with a caption

The caption names the table and is read first by screen readers.

<table> <caption>Monthly website visitors, 2026</caption> <thead><tr><th>Month</th><th>Visitors</th></tr></thead> <tbody><tr><td>January</td><td>1,200</td></tr></tbody> </table>

Highlighting a column

<col> can set a background color for a whole column.

<table> <colgroup> <col> <col style="background: #fff7d6"> </colgroup> <tr><th>Plan</th><th>Pro</th></tr> <tr><td>Storage</td><td>100 GB</td></tr> </table>

Fixed column widths

With table-layout: fixed, widths on col are respected and big tables render faster.

<style> table { table-layout: fixed; width: 100%; } </style> <table> <colgroup><col style="width: 30%"><col style="width: 70%"></colgroup> … </table>

Caption at the bottom

The CSS caption-side property moves the caption below the table.

<style> caption { caption-side: bottom; font-size: 0.9rem; color: #666; padding-top: 0.5rem; } </style>

<caption> vs <figcaption>

A <caption> belongs inside the table, as its first child, and gives the table an accessible name. A <figcaption> belongs to a <figure>, which can wrap a table together with a longer explanation, a source note or a chart.

For most tables, a caption is all you need. Use a figure with figcaption when the table is a numbered “Figure 3” in a report, or when it sits alongside other content that shares the same caption — and then skip the table caption so it isn’t named twice.

<caption><figcaption>
Goes in<table> (first child)<figure>
Names the table for screen readersYesVia the figure
Best forMost tablesReport figures, table + notes

Common mistakes to avoid

  • A heading or paragraph instead of caption. It isn’t linked to the table, so screen readers don’t announce it with the table.
  • Styling text with col. Only border, background, width and visibility work on col; font and color don’t.
  • Caption anywhere but first. It must be the very first child of the table.
  • A span that doesn’t match. <col span="2"> must match the number of columns you mean to cover.

Accessibility & SEO tips

  • Write captions that describe the content, like “Prices for 2026 plans”, not just “Table 1”.
  • A clear caption helps search engines understand what the table shows, which helps with table-style featured snippets.
  • Color alone shouldn’t carry meaning in highlighted columns; add a label such as “Most popular”.

Browser support

Supported in every browser, including Chrome, Edge, Firefox, Safari and their mobile versions — it has been part of HTML since the very first versions.

Related tags

Frequently asked questions

Why use <caption> instead of a heading above the table?
A <caption> is tied to its table, so screen readers announce it as the table's name when users reach it. A separate heading isn't connected in the same way. Move it below the table with caption-side: bottom if you prefer.
Why don't my CSS styles on <col> work?
Only a few properties apply to <col> and <colgroup>: background, border (with border-collapse: collapse), width and visibility. For anything else, such as text color or alignment, style the cells, for example with td:nth-child(3).
Where must <caption> go?
It must be the very first child of the <table>, before any <colgroup>, <thead> or rows.
Can I hide a table caption but keep it for screen readers?
Yes. Use a visually-hidden CSS class on the caption, so it isn't shown but is still announced.
Can <colgroup> be used without <col>?
Yes. <colgroup span="3"> groups three columns on its own. Use <col> inside it when you need to style individual columns.
How do I set column widths in an HTML table?
Put <col style="width: …"> in a <colgroup>, or set widths on the first row's cells. Add table-layout: fixed to make the browser follow them exactly.