HTML <thead> Tag

The <thead> tag contains the row(s) that make up the header of the table. The header contains one or more rows at the top of the table.




A styled <thead> tag.

First Name Last Name
Denice Hobermann
Paulo Cornell
Jane Hollander
  table.tb { width: 300px; border-collapse: collapse; }
  .tb th, .tb td { border: solid 1px #777; padding: 5px; }
  .tb thead { background-color:lightblue; }

<table class="tb">
      <th>First Name</th>
      <th>Last Name</th>
thead = table header
tbody = table body
tfoot = table footer

Using <thead>

Tables can be partitioned in 3 logical parts: <thead>, <tbody> and <tfoot>.

The <thead> tag creates a table header at the beginning of a table.

<thead> is used to style all header rows and columns as a group.

More Examples

A <thead> element that styles the header row.

First name Last name Email City Country
Tim Hallman Dallas USA
Jelle van Loenen Arnhem Netherlands
Jose Lopez Manila Philippines
Jeroen Harmsma The Hague Netherlands
Sunil Gupta Mumbai India
Henry Wong San Francisco USA
Cindy Velasquez Mexico City Mexico
This table has 7 data rows
 table.tbl { width:100%; border-collapse: collapse; }
 .tbl th, .tbl td { padding:3px; border: 1px solid #999; }
  .tbl thead { background-color: #3630a3; color: white; }

<table class="tbl">

    <th>First name</th>
    <th>Last name</th>

    <td>van Loenen</td>
  </tr> <tr>
    <td>The Hague</td>
    <td>San Francisco</td>
    <td>Mexico City</td>

   <td colspan="5">This table has 7 data rows</td>


Attributes for <thead>

The <thead> element has no attributes, but it does accept global attributes.
The following are commonly used.

Attribute Value Description
id    identifier Defines a unique identifier for the thead element.
class    classnames Sets one or more CSS classes to be applied to the thead element.
style    CSS-styles Sets the style for the thead element.
data-*    value Defines additional data that can be used by JavaScript.
hidden    hidden Specifies whether the thead element is hidden.

For additional global attributes see our global attributes list.

Obsolete Attributes

Do not use the attributes listed below.  They are no longer valid on thead in HTML5.

Attribute Description Alternative
align Aligns the content in the thead element. CSS text-align
bgcolor Defines the background color for the thead element. CSS background-color
char Aligns content to a character, for example "," or ".". CSS text-align
charoff Shifts column data to the right relative to char attribute. CSS text-align
valign Sets the vertical alignment of content in the thead element. CSS vertical-align

Table Tags

The <thead> tag is part of a group of tags that are used to create HTML tables. This group is referred to as the Table tag group. Together, these tags allow you to create comprehensive HTML tables.

Here is a list of table tags

Element Description
<table> Creates a table that contains elements listed below
<caption> Creates a caption above or under a table
<colgroup> Creates a container for col elements
<col> Creates a style for one or more columns in a table
<thead> Creates a table header that can style all header cells
<tbody> Creates a table body that can style all data cells
<tfoot> Creates table footer that can style all footer cells
<tr> Creates a table row that contains table cells
<th> Creates a table header cell
<td> Creates a table data cell

Browser support

Here is when <thead> support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like