colgroup
A group of column definitions inside a table.
Learn Table Colgroup with practical examples for tables, lists, structured data relationships, accessibility, SEO and live practice.
HTML data structures
The colgroup and col elements describe columns before the table rows begin. They are most useful when a whole column needs the same styling.
Colgroup does not replace table headers. Headers explain meaning. Colgroup gives column-level structure for presentation.
Use it when a column needs consistent width, background or emphasis across many rows.
A group of column definitions inside a table.
A single column styling hook.
Lets one col definition apply to multiple columns.
Useful for width, background and repeated emphasis.
Syntax and structure
A colgroup belongs after caption and before thead, tbody or tr content.
<table>
<caption>Package comparison</caption>
<colgroup>
<col class="feature-column">
<col span="2" class="price-column">
</colgroup>
<tr><th scope="col">Feature</th><th scope="col">Basic</th><th scope="col">Pro</th></tr>
<tr><th scope="row">Support</th><td>Email</td><td>Priority</td></tr>
</table>
<tr> <td class="price-column">EUR 75</td> <td class="price-column">EUR 95</td> <td class="price-column">EUR 120</td> </tr>
Rules that matter
Tables and lists are small elements with big structural value. They help users scan, compare, follow steps and understand how pieces of information belong together.
Colgroup is useful when a whole column needs a repeated visual treatment.
Colgroup is not a semantic replacement for th.
Not every CSS property behaves the same on col elements.
span="2" is clean when adjacent columns share the same style.
If colgroup makes the table harder to read, classes on cells may be better.
Put caption first, then colgroup, then table sections or rows.
Production thinking
This matters because repeated classes across dozens of cells are easy to mistype. Colgroup can keep column-level styling centralized.
Colgroup is mainly structural and presentational. Screen reader clarity still comes from caption and headers.
Colgroup can reduce repeated markup in large comparison tables, but test the exact styling you expect in browsers.
Column styling does not create meaning for search engines. Use clear headers and text content for meaning.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.