Spread the love

The HTML <col> Tag is used to specify the general column properties for each column in the <colgroup> interval section of the Associate Hypertext Markup Language Table.

The <col> Tag is useful when you need to use the general rules for each column cell instead of applying one by one.

Note:- Note: The <col> Tag does not require a closing tag in HTML but it does require a closing </col> Tag in XHTML.

Example:-

<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
   <title>
      HTML col tag
   </title>
</head>
<body>
<h1>This is HTML col Tag Example</h1>
<table border="1">
  <colgroup>
    <col span="1" style="background-color:red;">
    <col span="2" style="background-color:yellow;">
  </colgroup>
  <tr>
    <th>Roll No.</th>
    <th>Name</th>
    <th>Grade</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>Khushal</td>
    <td>A+</td>
  </tr>
</table>
</body>
</html>

Output:-


Spread the love

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *