View video tutorial

HTML <colgroup> Tag

HTML

The <colgroup> defines a group of one or more columns.

HTML <colgroup> Tag


The <colgroup> HTML element defines a group of columns within a table for formatting.

It helps to apply style to entire columns.

Example

<table>
    <colgroup>
        <col span="2" style="background-color:rgb(73, 108, 131);">
        <col style="background-color:#f24576;" width='150'>
    </colgroup>
    <tr>
        <th>Last Name</th>
        <th>First Name</th>
        <th>Salary</th>
    </tr>
    <tr>
        <td>Greenberg</td>
        <td>Nancy</td>
        <td style="text-align:center;">$8000</td>
    </tr>
</table>
Try it Now »

Click on the "Try it Now" button to see how it works.


Element Attributes

Attribute Value Description
span number This attribute contains a positive integer which indicates the number of consecutive columns in the colgroup element span. Default value is 1.

Global attributes

Global attributes may be applied on all elements, although some elements may have no effect on them.

<accesskey>, <class>, <contenteditable>, <contextmenu>, <data-*>, <dir>, <draggable>, <dropzone>, <hidden>, <id>, <lang>, <spellcheck>, <style>, <tabindex>, <title>, <translate>.

Learning with HTML Editor "Try it Now"

You can edit the HTML code and view the result using online editor.