Recommended Free Tools
The HTML <colgroup> element groups one or more columns in a <table>, primarily so you can style those columns together. Put it after an optional <caption> and before <thead>, <tbody>, <tfoot>, or individual rows. It does not create cells or provide header semantics; use <th>, scope, and a caption for that.
What <colgroup> does
A table’s columns are defined by the cells in its rows. <colgroup> adds a structural layer that lets you describe consecutive columns as a group. This is useful for column backgrounds, minimum widths, borders in collapsed-border tables, and column visibility. It does not add rows, cells, labels, or screen-reader relationships.
See the MDN colgroup reference and MDN table basics for the platform definitions.
Where it belongs in a table
The permitted order is an optional caption, then column groups, then the table’s row groups or rows:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
<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>
In this example, the first <col> describes column one. The second describes the next two columns because its span is 2. Column positions are determined by the table’s columns, not by text appearing inside the cells.
Two ways to describe columns
Choose either a span on an otherwise empty <colgroup>, or child <col> elements. A <colgroup> with child columns must not also have its own span attribute.
Rank #2
| Approach | Example | Best when |
|---|---|---|
| Group-level span | <colgroup span="3"></colgroup> |
Several adjacent columns share one treatment and need no separate classes. |
Child <col> elements |
<colgroup><col><col span="2"></colgroup> |
Different column groups need distinct classes, styles, or spans. |
The span value is a positive integer greater than zero. If a <col> has no span, its default is 1. This is the valid group-level form:
<table>
<colgroup span="3" class="numeric-columns"></colgroup>
<tr><td>A</td><td>B</td><td>C</td></tr>
</table>
Do not write <colgroup span="3"><col>...</colgroup>; when child <col> elements are present, the group-level span is not permitted.
Rank #3
What CSS can style
Column groups intentionally support a narrow set of CSS effects. MDN documents background properties, borders when the table uses border-collapse: collapse, visibility: collapse, and width. On a column group, width acts as a minimum width for the grouped columns.
table {
border-collapse: collapse;
}
.region-column {
background: #eef;
}
.quarter-columns {
background: #efe;
}
Backgrounds are painted behind backgrounds on columns, row groups, rows, and cells. An opaque <td> or <th> background can therefore hide the color applied to <colgroup> or <col>. If you need text alignment, typography, padding, or another property that column groups do not affect, style the <th> and <td> cells instead.
Hiding a column group
visibility: collapse is the column-group behavior documented by MDN for collapsing columns. Test the result in the browsers that matter to your application, especially when the table includes spanning cells. Do not confuse this with a class name or a background-color example: a colored column is not hidden.
Cell selectors as an alternative
For tables without colspan, positional selectors such as td:nth-of-type() can target cells directly. Once colspan is involved, positional matching requires more careful selectors because one cell can occupy multiple columns. Use a column group when the styling is genuinely column-wide, and cell selectors when the desired property is not supported on columns.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
Column styling is not table accessibility
Give the table a concise <caption> that states its purpose. Use <th> for header cells and set scope="col" for column headers or scope="row" for row headers when the relationships are straightforward. These elements provide meaning and navigation cues; <colgroup> only groups columns for structure and styling.
<table>
<caption>Support tickets by priority</caption>
<colgroup><col class="priority"></colgroup>
<thead>
<tr>
<th scope="col">Priority</th>
<th scope="col">Open</th>
</tr>
</thead>
...
</table>
A caption and header cells help people understand the data; adding a <colgroup> alone does not improve accessibility or establish those header relationships.
Common mistakes and fixes
- Putting the element after the header: move
<colgroup>before<thead>,<tbody>,<tfoot>, and rows. - Combining group
spanwith child columns: remove the group-level attribute or remove the child<col>elements. - Expecting arbitrary CSS to cascade to cells: apply unsupported properties directly to
<th>and<td>. - Not seeing a background: inspect cell, row, and column backgrounds; an opaque cell background is painted over the group.
- Using it as a header: keep the semantic header in
<th>and usescopewhere appropriate. - Counting columns incorrectly: account for every
<col>span and for cells that usecolspan.
Is <colgroup> still valid?
Yes. MDN marks the element as widely available across browsers since July 2015. That is general compatibility guidance, not a guarantee that every complex combination of spanning, collapsing, and CSS rendering will look identical everywhere. Test unusual layouts in your supported browsers.
Quick Recap
When to use it
- Use
<colgroup>when several adjacent columns share a background, minimum width, border treatment, or collapse behavior. - Use separate
<col>elements when columns need different classes or spans. - Use direct cell styling when you need alignment, padding, fonts, or other properties outside the column-group set.
- Always retain captions and header cells for the table’s meaning and accessible navigation.
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.




