HTML Tags

HTML <thead> Tag

The <thead> tag in HTML defines the header section of a table.
It groups all header rows (<tr>) that typically contain column headings defined by <th> tags.
This element improves readability, accessibility, and enables consistent styling or scripting across header rows.

Syntax

html

<table>
  <thead>
    <tr>
      <th>Heading 1</th>
      <th>Heading 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Data 1</td>
      <td>Data 2</td>
    </tr>
  </tbody>
</table>

Attributes

AttributeDescription
(None)The <thead> tag does not have any specific attributes. You can use global attributes like class, id, or style.

Example

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Thead Tag Example</title>
  <style>
    table {
      border-collapse: collapse;
      width: 70%;
      margin: 20px auto;
      text-align: center;
    }
    thead {
      background-color: #29AB87;
      color: white;
    }
    th, td {
      border: 1px solid #555;
      padding: 10px;
    }
    tbody tr:nth-child(even) {
      background-color: #f9f9f9;
    }
  </style>
</head>
<body>

  <h2>HTML Table with Thead Example</h2>

  <table>
    <thead>
      <tr>
        <th>Planet</th>
        <th>Distance from Sun</th>
        <th>Moons</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Mercury</td>
        <td>57.9 million km</td>
        <td>0</td>
      </tr>
      <tr>
        <td>Earth</td>
        <td>149.6 million km</td>
        <td>1</td>
      </tr>
      <tr>
        <td>Jupiter</td>
        <td>778.5 million km</td>
        <td>79</td>
      </tr>
    </tbody>
  </table>

</body>
</html>

Output

Browser Output

html

Displays a table with a green header row defined inside <thead>.
Please use our TryIt editor to view and modify the example live.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

All modern browsers fully support the <thead> element.

Notes

  • The <thead> element should appear before <tbody> and <tfoot> within a table.
  • It improves data organization and helps browsers render large tables efficiently.
  • Useful for styling headers and keeping them fixed while scrolling with CSS or JavaScript.
  • Tables without <thead> are still valid but less structured.

Conclusion

The <thead> tag defines a clear and accessible table header section, separating structure from content.
It’s especially helpful for data tables, reports, and dashboards where clarity and readability are essential.