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
align
|
Set the alignment of the text content.
|
valign
|
Set the vertical alignment of the text content.
|
char
|
Set the alignment of the content inside the <thead> element to a character.
|
charoff
|
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
Example:Â The content within <thead>
includes labels for each column, for better representation of table data.
HTML
<!DOCTYPE html>
< html >
< body >
< center >
< h1 >GeeksforGeeks</ h1 >
< h2 >thead Tag</ h2 >
< table >
< thead >
< tr >
< th >Name</ th >
< th >User Id</ th >
</ tr >
</ thead >
< 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
Last Updated :
13 Dec, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...