HTML <colgroup>Tag
Examples
The <colgroup> and <col> tags set the background color for three columns in a table:
<colgroup>
<col span="2" style="background-color:red">
<col style="background-color:yellow">
</colgroup>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
</table>
Try it Yourself »
Browser Support
![]()
All major browsers support the <colgroup> tag.
Definition and Usage
The <colgroup> tag is used to group columns in a table so that they can be formatted.
By using the <colgroup> tag, you can apply styles to entire columns without having to repeat styling for every cell or row.
Note:The <colgroup> tag can only be used inside a <table> element, after any <caption> element, and before any <thead>, <tbody>, <tfoot>, or <tr> element.
Tip:If you want to define different attributes for a column in a <colgroup>, use the<col>tag.
Differences Between HTML 4.01 and HTML5
HTML5 no longer supports most of the attributes in HTML 4.01.
Attributes
| Attribute | Value | Description |
|---|---|---|
| align | left right center justify char |
Not supported in HTML5.Specifies the horizontal alignment of the content in a column group. |
| char | character | Not supported in HTML5.Specifies which character to align the content in a column group. |
| charoff | number | Not supported in HTML5.Specifies the offset of the first alignment character. |
| span | number | Specifies the number of columns a column group should span. |
| valign | top middle bottom baseline |
Not supported in HTML5.Defines the vertical alignment of the content in a column group. |
| width | pixels % relative_length |
Not supported in HTML5.Specifies the width of a column group. |
Global Attributes
The <colgroup> tag supportsthe global attributes of HTML.。
Event Attributes
The <colgroup> tag supportsthe event attributes of HTML.。
Other Extensions