<thead> Tag in HTML | Grouping Header Content in Tables

The <thead> tag in HTML is used to group header content in a table. It helps in defining a block of rows that represent column headers, which are typically displayed at the top of the table. Using <thead> makes tables more accessible and structured, especially for screen readers.

Key Points on <thead> Tag:

Syntax of <thead> Tag:

Syntax Example

<table>
            <thead>
                <tr>
                    <th>Header 1</th>
                    <th>Header 2</th>
                    <th>Header 3</th>
                </tr>
            </thead>
            <tbody>
                <!-- Table body rows go here -->
            </tbody>
        </table>

Example of <thead> Tag in HTML:

This example demonstrates a table with a header row defined using the <thead> tag.

Code Example

<table border="1">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Age</th>
                    <th>City</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Alice</td>
                    <td>24</td>
                    <td>New York</td>
                </tr>
                <tr>
                    <td>Bob</td>
                    <td>30</td>
                    <td>Los Angeles</td>
                </tr>
            </tbody>
        </table>

Output

Name Age City
Alice 24 New York
Bob 30 Los Angeles

Attributes of <thead> Tag:

Advantages of Using <thead> Tag:

The <thead> tag provides an efficient way to structure table headers in HTML, improving readability, accessibility, and print layout.