Colgroup Tag in HTML5

In this article I am going to describe about the implementation and use of Colgroup Tag in HTML5.
  • 2149

Colgroup Tag

The <colgroup> tag is used to gather  more than two columns in the table. This tag is used to do easy formatting of columns rather than changing the style of  each cell one by one. This tag is used after <caption> tag and within <table> tag only. The <colgroup> tag can contain legal no. of column  <col> tag only. This tag is used when we want same style for the columns.

Note: The <colgroup> tag must be a child of a <table> element, after any <caption> elements and before any <thead>, <tbody>, <tfoot>, and <tr> elements.


<colgroup span="value"></colgroup>

Browser Support

<colgroup> tag is supported in all major browsers.


   Attribute      Value                  Description
    span    number  specifies the number of column the column group should span.

Most of the attribute of HTML4.01 are not supported in HTML5.Other attributes like width, align, char, valign are not supported by HTML5.

The value of "span" attribute is an integer no i.e. no of columns to be grouped which must be a valid no.

Example of colgroup Tag in HTML5

<!DOCTYPE html>

<html lang="en" xmlns="">


    <meta charset="utf-8" />

    <title>Colgroup in HTML5</title>



            <col span="2" style="background-color: red" />

            <col style="background-color: yellow" />

            <col style="background-color: pink" />



            <th>Id </th>









            <td>Software Developer</td>

















    <p>ColGroup in HTML5</p>





© 2020 DotNetHeaven. All rights reserved.