HTML5 <colgroup> Tag


  <colgroup span="2" style="background:red"></colgroup>
    <th>Tag Num</th>
    <td>HTML Data</td>
Code it Online »

Definition and Usage

The <colgroup> tag is used to group columns in a table for formatting.

The <colgroup> tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.

The <colgroup> tag can only be used inside a table element.

Differences Between HTML 4.01 and HTML5

Most of the attributes from 4.01 are not supported in HTML5.

Tips and Notes

Note: The colgroup element can only contain col elements.

Note: The colgroup element does not create columns. To create columns, you must specify td elements within a tr element.

Hint: Use the colgroup element if you want to specify the same attribute values to a group of columns.

Hint: Use the col element when you want to specify different attribute values to more than one table column.


Attribute Value Description
align left
Not supported in HTML5
char character Not supported in HTML5
charoff number Not supported in HTML5
span number Defines the number of columns the column group should span
valign top
Not supported in HTML5
width %
Not supported in HTML5

Standard Attributes

The <colgroup> tag also supports the Standard Attributes in HTML5.

Event Attributes

The <colgroup> tag also supports the Event Attributes in HTML5.

Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!