HTML colgroup tag

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


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
Try </>

Specific uses

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

Related Tags

<table> table element represents data in the form of table.
<table> <tr><td> table data </td></tr></table>
<tr> tr element defines a table row in the table.
<table> <tr> table row </tr> </table>
<td> td defines one cell of data in the table.
<table><tr> <td> Cell </td> </tr></table>
<col> col element defines a column in a cloumn group.
<table><colgroup> <col> A column </col> </colgroup></table>

Tag omission

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

Global Attributes

All global attributes are applicable on colgroup element.

Specific Attributes

span If colgroup does't contain any column then this attribute should be use.
<colgroup span="2"> <col></col> </colgroup>

Was this article helpful?




Get the newsletter