HTML <colgroup> Tag

The HTML <colgroup> tag is used to specify a group of columns with common properties inside a table. The tag can include several <col> elements that define column properties.

The <colgroup> tag is nested inside a <table> tag, before <thead>, <tbody>, <tfoot> and <tr>, and after <caption>, if it is used (in the <caption> tag, the table name is inserted).

A single HTML table can include several <colgroup> tags.


The <colgroup> tag comes in pairs. The content is written between the opening (<colgroup>) and closing (</colgroup>) tags.

Example of the HTML <colgroup> tag:

<!DOCTYPE html>
    <title>Title of the document</title>
      table, th, td {
        border: 1px solid #666;
        <col span="2" style="width:20%; background-color:#eee;">
        <col style="width:10%; background-color:#8ebf42;">
        <td>Mary Nicolson</td>
        <td>John Johnson</td>


colgroup exemple


Attribute Value Description
align Sets the alignment of the column contents.
Not supported in HTML5.
left Aligns to the left.
right Aligns to the right.
center Aligns the center.
justify Stretches the lines so that each line has equal width.
char Aligns a special character with a minimum offset, which is defined by the char and charoff attributes.
char character Aligns the contents of the column with the specified character. Used only if the attribute align="char".
Not supported in HTML5.
charoff number Shifts the contents of the cell relative to the specified character set as the value of the attribute to the right (positive values) or to the left (negative values). Used only if the attribute align="char".
Not supported in HTML5.
span number Sets the number of columns, the characteristics of which are defined by the <col> element. The number must be a positive integer. If the parameter is not specified, the default value is 1.
valign Aligns the content vertically.
top Aligns at the top of the line.
bottom Aligns the bottom edge.
middle Aligns in the middle.
baseline Aligns the baseline.
Not supported in HTML5.
width %
Sets the width of the column.
Not supported in HTML5.

The <colgroup> tag also supports the Global Attributes and the Event Attributes.

Browser support

chrome edge firefox safari opera

Practice Your Knowledge

What is the correct depiction and use case of the HTML <colgroup> tag?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?