HTML <thead>Tag: The HTML<thead> tag groups header content in an HTML table. And the <thead> element is used in conjunction with the <tbody> and <tfoot> elements to specify each part of a table (header, body, footer). Browsers can use these elements to enable scrolling of the table body independently of the header and footer. And also, when printing a large table that spans multiple pages, these elements can enable the table header and footer to be printed at the top and bottom of each page.
HTML <thead>Tag
This HTML thead tag supports both the global and the event attributes.
Attributes
- align: Set the alignment of the text content.
- valign: Set the vertical alignment of the text content.
- char: Set the align of content inside the <thead> element to a character.
- charoff: It is used to sets the number of characters that will be aligned from the character specified by the char
- attribute. The value of these attributes is in numeric form.
Syntax:<thead> Text</thead>
Browser compatibility
The HTML<thead> tag is supported by different types of browsers.
- Chrome
- Firefox
- Opera
- Safari
- Internet Explorer
Example:
<!DOCTYPE html> <html> <head> <style> thead {color:green;} tbody {color:blue;} tfoot {color:red;} table, th, td { border: 1px solid black; } </style> </head> <body> <table> <thead> <tr> <th>Month</th> <th>Savings</th> </tr> </thead> </table> </body> </html>
Output:
Attributes that are supported by the <thead> tag
Attribute | Value | Description |
---|---|---|
align | right left center justify char |
Aligns the content inside the element |
char | character | Aligns the content inside the element to a character |
charoff | number | Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute |
valign | top middle bottom baseline |
Vertical aligns the content inside the element |