Html 5 Colgroup tag

In the <colgroup> tag is used to indicate group of columns for a table. The <colgroup> tag you must use inside of <table> tag or after <caption> tag or before any <tr>,<thead>,<tbody> and <tfoot> tags. Which tag does not create column if you need to create column to use <td> tag inside of <tr> tag.In the colgroup element is an empty element.

Syntax:

<table>
  <colgroup> ... </colgroup>
  <tr>
    <td> ... </td>
  </tr>
</table>

Example Code

<table border="1">
  <colgroup span="3" style="background-color:#0000CC"> </colgroup>
<tr>
  <td> First Column  </td>
  <td> Second Column  </td>
  <td> Third Column  </td>
  <td> Fourth Column  </td>
</tr>
</table>

Out Put:



  First Column     Second Column     Third Column     Fourth Column  

In the above example <colgroup> tag has been added to inside of table.In the first third column has been grouped that columns was highlighted with blue color.





Content