HTML <colgroup> tag

HTML <colgroup> tag : Definition

• The HTML <colgroup> tag represents a group of columns in a table, so that you can apply formatting or add classes to the group instead of each individual cell..



<colgroup> tag example :


<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>



<h1>The col element example</h1>

<table>
  <colgroup>
    <col span="2" style="background-color:red">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ZIP Code</th>
    <th>Name</th>
    <th>Address</th>
  </tr>
  <tr>
    <td>815603</td>
    <td>Rahul</td>
    <td>Ranchi</td>
  </tr>
  <tr>
    <td>560029</td>
    <td>Prayag</td>
    <td>Bangalore</td>
  </tr>
</table>



</body>
</html> 


OUTPUT :


ZIP Code Name Address
815603 Rahul Ranchi
560029 Prayag Bangalore