HTML colgroup tag

HTML <colgroup> tag groups all the columns. It contains one or more columns. colgroup is the child of table element.

<table class="demoBox">
  <col style="background-color:lightgreen;">
  <col style="background-color:lightblue;">
  <col style="background-color:lightyellow;">
  <td>Unitd States</td>


Countries Population Area
China 7,432,663,275 9,572,900
India 1,382,323,332 3,287,263
Unitd States 324,118,787 9,525,067

Tag Uses

Specific uses of <colgroup> tag

HTML colgroup element contains one or more columns. It can style more than one columns rather than individually.

Tag omission

The closing tag (</colgroup>) of colgroup may be omitted.

Global Attributes

All global attributes are applicable on colgroup element.

Tag Attributes

Attributes that are applicable to <colgroup> tag

If colgroup does't contain any column then this attribute should be use.

<colgroup span="2"> <col></col> </colgroup>

Was this article helpful?