The HTML <thead> tag is used to provide a header to the group of content in an HTML table. Combining the <tbody> and <tfoot> elements with the <thead> element can help to specify each part of a table, i.e., the header, body, and footer. By using these elements, browsers allow the table body to scroll separately from the header and footer. To use the <thead> element, there must be more than one <tr> tag inside the table.
Syntax
<thead>
// Table head Contents...
</thead>
Attributes
Attributes |
Descriptions |
---|---|
Set the alignment of the text content. |
|
Set the vertical alignment of the text content. |
|
Set the alignment of the content inside the <thead> element to a character. |
|
It is used to set 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. |
Note
-
The
<thead>
tag also supports the Global Attributes and Event Attributes in HTML. - The attribute values used with <thead> are deprecated in the HTML5.
Example: The content within <thead>
includes labels for each column, for better representation of table data.
<!DOCTYPE html> < html >
< body >
< center >
< h1 >GeeksforGeeks</ h1 >
< h2 >thead Tag</ h2 >
< table >
<!-- thead tag starts from here -->
< thead >
< tr >
< th >Name</ th >
< th >User Id</ th >
</ tr >
</ thead >
<!-- thead tag ends here -->
< tbody >
< tr >
< td >Ram</ td >
< td >@ram_b</ td >
</ tr >
< tr >
< td >Shashank</ td >
< td >@shashankla</ td >
</ tr >
</ tbody >
</ table >
</ center >
</ body >
</ html >
|
Output:
Supported Browsers
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Opera 12.1 and above
- Safari 1 and above