HTML <col> tag

HTML <col> tag : Definition

• The HTML <col> tag is used to set the column properties for each column.

• It is generally found within a <colgroup> element.

• The <col> tag is generally used for applying styles to entire columns, instead of repeating the styles for each cell and each row.



<col> 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 :


The col element example

ZIP Code Name Address
815603 Rahul Ranchi
560029 Prayag Bangalore