HTML - how to use <colgroup> tag

The HTML <colgroup> - defines a group of one or more columns which can be used along with the col tag for formatting. The <colgroup> tag can be used to style to whole columns. The col tag needs to be defined for styling the columns.

The <colgroup> tag must be a child of a <table> element, after any <caption> elements and before any other table related elements.


The colgroup tag supports the global and event attributes.


<table> <colgroup> <col style="background-color:red"> <col style="background-color:blue"> <col style="background-color:yellow"> </colgroup> <tr> <th>Country</th> <th>Capital</th> <th>City</th> </tr> <tr> <td>USA</td> <td>Washington</td> <td>New York</td> </tr> <tr> <td>India</td> <td>New Delhi</td> <td>Chennai</td> </tr> </table>