HTML <thead> Tag
To define a group of rows as the header of an HTML table, the HTML <thead> tag is used. It is used as a child of the <table> element along with the <tbody> and <tfoot> tags. The HTML <thead> tag, however, does not affect the layout of the table but is used for providing semantic information. One or more <tr> elements must be placed within a <thead> tag.
Syntax:
<thead> <tr></tr> <tr></tr> </thead>
Example:
<!DOCTYPE html> <html> <head> <style> thead {background-color:lightgray;} tbody {background-color:pink;} tfoot {background-color:wheat;} table, th, td { border: 2px solid brown; } </style> </head> <body> <table> <thead> <tr> <th>NAME</th> <th>AGE</th> </tr> </thead> <tbody> <tr> <td>Tom</td> <td>20</td> </tr> <tr> <td>Jerry</td> <td>10</td> </tr> </tbody> <tfoot> <tr> <td>Average</td> <td>15</td> </tr> </tfoot> </table> </body> </html>
Explanation:
In the above example, we have displayed the use of the HTML <thead> tag along with the other HTML table tags. We thus defined a header in the above table.
Tag specific Attributes:
Attribute | Value | Uses | HTML 5 |
align | right
left center justify char |
Used to define the content alignment inside the <thead> element. | Not Supported in HTML5. |
char | character | Used to define the content alignment of the <thead> tag to the character. | Not Supported in HTML5. |
charoff | Number | Used to define the number of characters the <thead> content will be aligned from the character specified by the char attribute. | Not Supported in HTML5. |
valign | top
middle bottom baseline |
Used to define the vertical content alignment inside the <thead> element. | Not Supported in HTML5. |
Global Attributes:
The HTML Global attributes are supported by the HTML <thead> tag.
Event Attributes:
The HTML Event attributes are supported by the HTML <thead> tag.
Supporting Browser:
Chrome, IE, Firefox, Opera, and Safari.