The col tag in HTML is used to set column properties for each column. These columns should be within a <colgroup> element.
Following is the attribute −
- span: The number of columns a <col> element should span
Let us now see an example to implement the col tag in HTML −
Example
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 2px solid black;
}
</style>
</head>
<body>
<h2>ICC Rankings</h2>
<table>
<colgroup>
<col span="2" style="background-color:magento;">
<col style="background-color:blue;">
</colgroup>
<tr>
<th>Player</th>
<th>Country</th>
<th>Rank</th>
</tr>
<tr>
<td>Jack</td>
<td>WI</td>
<td>1</td>
</tr>
<tr>
<td>Tom</td>
<td>AUS</td>
<td>2</td>
</tr>
<tr>
<td>Virat</td>
<td>IND</td>
<td>3</td>
</tr>
<tr>
<td>Steve</td>
<td>AUS</td>
<td>4</td>
</tr>
<tr>
<td>Kane</td>
<td>NZ</td>
<td>5</td>
</tr>
<tr>
<td>David</td>
<td>AUS</td>
<td>6</td>
</tr>
</table>
</body>
</html>Output
