HTML <colgroup> Tag

Description

The <colgroup> HTML element is intended to specify the width and style of one or more columns of the table. This element allows you to reduce the code of the table by reducing duplicate attributes, and if it is available, the browser starts showing the contents of the table, without waiting for it to fully load. The <colgroup> element can be used in combination with <col> , which defines the characteristics of one or more columns.
Usually, a closing tag is not required, but if the <colgroup> acts as a container for the <col> elements, then the </colgroup> tag should be added at the end of the group.

Properties

Permitted Parents
A <table> element. The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element.
Content
0 or more <col> elements
Start/End Tags
Start tag: required, End tag: required

Example

<table border="1">
<colgroup span="2" style="background-color: #DFF0D8;"></colgroup>
<col span="1" style="background-color: lightblue;">
<tr>
<th>Country</th>
<th>Capital</th>
<th>Population (in millions)</th>
<th>Language</th>
</tr>
<tr>
<td>USA</td>
<td>Washington D.C.</td>
<td>331</td>
<td>English</td>
</tr>
<tr>
<td>France</td>
<td>Paris</td>
<td>67</td>
<td>French</td>
</tr>
<tr>
<td>Germany</td>
<td>Berlin</td>
<td>83</td>
<td>German</td>
</tr>
</table>

Attributes

Attribute Definition
span Specifies how many columns to span.

Global Attributes

The <colgroup> tag also supports the Global Attributes in HTML5

Event Attributes

The <colgroup> tag also supports the Event Attributes in HTML5

Browser Support

The following table will show you the current browser support for the HTML <colgroup> tag.

Desktop
Edge Chrome Firefox Opera Safari
1211154
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
184143.214.4

Last updated by CSSPortal on: 30th March 2024