<Colgroup> HTML Tag

In this article I will discuss the colgroup tag of HTML.
  • 2269

The HTML colgroup tag is used for specifying properties for a group of columns within a table.The <colgroup> tag is used to group columns in a table for formatting.This tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.This tag can only be used inside a <table> element.

Example

<html>

<head>

    <title></title>

</head>

<body>

  <table width="100%" border="1">

  <colgroup span="2" style="background-color:Gray;"></colgroup>

  <colgroup span="2"style="background-color:Silver;"></colgroup>

  <tr>

    <th>Id</th>

    <th>Name</th>

    <th>Address</th>

    <th>Contact_no</th>

  </tr>

  <tr>

    <td>3476896</td>

    <td>Richa</td>

    <td>Delhi</td>

    <td>123456789</td>

  </tr>

  <tr>

    <td>1234321</td>

    <td>Megha</td>

    <td>Delhi</td>

    <td>987654321</td>

  </tr>

   <tr>

    <td>1254321</td>

    <td>Ajay</td>

    <td>Noida</td>

    <td>983456219</td>

  </tr>

</table>

</body>

</html> 


Output
 

Id Name Address Contact_no
3476896 Richa Delhi 123456789
1234321 Megha Delhi 987654321
1254321 Ajay Noida 983456219


Ask Your Question 

Got a programming related question? You may want to post your question here
 
© 2020 DotNetHeaven. All rights reserved.