<colgroup>: The HTML Column Group Element

1 Description

The HTML <colgroup> element exists so that you can easily manipulate the styling of one or more columns in a <table>.

The <colgroup> element should always be a direct descendant of the <table> element. The <colgroup> element should appear after a <caption> element if a <caption> element is present, and before a <thead>, <tbody>, or <tfoot> element. There should be at most one <colgroup> element in each <table>.

2 Examples

<!DOCTYPE html>
<html>
    <head>
        <title>Example Page</title>
    </head>
    <body>
        <table>
            <caption>Weather forecast for the next 3 days.</caption>
            <colgroup>
                <col class="date"/>
                <col class="daily_low"/>
                <col class="daily_high"/>
            </colgroup>
            <thead>
                <tr>
                    <th colspan="3">Weather For The Next 3 Days</th>
                </tr>
                <tr>
                    <th>Day</th>
                    <th>Overnight Low (Fahrenheit)</th>
                    <th>Daily High (Fahrenheit)</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>2025-04-01, Tuesday</td>
                    <td>41 degrees</td>
                    <td>69 degrees</td>
                </tr>
                <tr>
                    <td>2025-04-02, Wednesday</td>
                    <td>45 degrees</td>
                    <td>72 degrees</td>
                </tr>
                <tr>
                    <td>2025-04-03, Thursday</td>
                    <td>44 degrees</td>
                    <td>76 degrees</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

This document was last updated: