colgroup

I. Description

The HTML colgroup element exists so that you can easily manipulate the styling of a column in an HTML table.

Some styling which you could apply to a column in an HTML table is, setting the background color of a column, setting the width of a column, setting the border properties of a column, etc.

The colspan element should always be a direct descendant of the table element. The colspan 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 colspan element in each table.

II. 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>