Use <colgroup> to group table columns so you can apply limited column-level styling. It does not create cells or identify headers: table rows, <th> and <td> still define the content and its relationships.
What <colgroup> does
A <colgroup> element represents one or more consecutive columns in an HTML table. Its main practical use is grouping columns for styling. It does not add a row or cell, and it does not make a column into a header.
For table structure and header meaning, use row elements and header cells. The MDN guide to HTML table basics explains the roles of captions, rows, and cells.
Where to put it
Put <colgroup> inside <table>, after an optional <caption> and before <thead>, <tbody>, <tfoot>, or direct <tr> elements. A table can use a caption to state its purpose, followed by column groups and then its rows.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errors#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Choose a column-group pattern
There are two common ways to describe the columns: give the group a span, or add one or more <col> children. Use child columns when you need to assign different classes or styles to different portions of the table.
| Pattern | Example | When to use it |
|---|---|---|
Group-level span |
<colgroup span="3"></colgroup> |
Describe three consecutive columns as one group. |
Child <col> elements |
<colgroup><col><col span="2"></colgroup> |
Describe columns or subgroups individually, including when they need separate classes. |
Do not combine a span attribute on <colgroup> with child <col> elements. The group-level span must be a positive integer greater than zero; if omitted, it defaults to 1. On an individual <col>, span likewise describes how many consecutive columns that element covers.
Rank #2
Example with separately styled columns
<table>
<caption>Quarterly revenue by region</caption>
<colgroup>
<col class="region-column">
<col span="2" class="quarter-columns">
</colgroup>
<thead>
<tr>
<th scope="col">Region</th>
<th scope="col">Q1</th>
<th scope="col">Q2</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">North</th>
<td>120</td>
<td>135</td>
</tr>
</tbody>
</table>
The first <col> covers one column because its span is omitted. The next covers two. Their positions correspond to the table’s columns, so the first group applies to Region and the second to Q1 and Q2. See MDN’s <colgroup> reference for the element’s content and attribute rules.
What CSS can style through a column group
CSS support for column groups is deliberately limited. The documented properties that affect <colgroup> are background properties, width, borders when the table uses border-collapse: collapse, and visibility: collapse. The CSS width on a column group sets a minimum width for its columns; it is not a general guarantee that the group will render at exactly that width.
.region-column {
background: #eef;
}
.quarter-columns {
background: #efe;
}
A column-group background is painted behind backgrounds on columns, row groups, rows, and cells. If cells have opaque backgrounds, they can cover the group color. For properties that do not apply to column groups—such as text alignment—style the relevant <th> and <td> cells instead.
visibility: collapse is a distinct behavior from a background color: it can collapse the columns represented by the group. Do not use it when the intention is merely to highlight a column.
Rank #4
Targeting cells by position
For a table without colspan, a selector such as td:nth-of-type(2) can target cells by position instead of using <colgroup>. With cells that span columns, positional selectors need more care because the cell’s position in a row does not always correspond directly to its visual column.
Keep column styling separate from table semantics
A <caption> gives the table a description, while <th> marks header cells. In the example, scope="col" identifies column headers and scope="row" identifies the row header. These elements provide meaningful table structure; <colgroup> only groups columns and does not establish those header relationships.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
There is no basis for treating <colgroup> itself as an accessibility or search-ranking feature. Use it for the column-grouping role it actually provides, and build the table’s headings and cells explicitly.
Is <colgroup> still supported?
Yes. MDN marks the element as widely available across browsers since July 2015. That is general compatibility guidance, not a promise that every styling detail will look identical in every browser.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

