HTML <thead> 元素用于定义 HTML 表格的标题。<thead> 标签与 <tbody> 和 <tfoot> 标签一起使用,它们定义了 HTML 表格中的表格标题、表格正文和表格页脚。
<thead> 标签必须是 <table> 元素的子元素,并且必须在任何 <tbody>、<tr> 或 <tfoot> 元素之前使用。
<thead> 标签内至少应包含一行 <tr> 元素。
<thead> <tr> </tr> </thead>
以下是关于 HTML <thead> 标签的一些规范
| 展示 | 排队 |
| 开始标签/结束标签 | 开始和结束标记 |
| 用法 | 表头 |
<!DOCTYPE html>
<html>
<head>
<title>HTML thead Tag</title>
<style>
table{
border-collapse: collapse;
margin: 15px;}
thead{
background-color:#005cb9;}
tbody{
background-color: #d4caca;}
th,td{
padding: 12px;}
</style>
</head>
<body>
<h2>Example of thead tag</h2>
<table border="1">
<caption>Population of India</caption>
<thead>
<tr>
<th>Year</th>
<th>Population</th>
</tr>
</thead>
<tbody>
<tr>
<td>2015</td>
<td>1,309,053,980</td>
</tr>
<tr>
<td>2016</td>
<td>1,324,171,354</td>
</tr>
<tr>
<td>2017</td>
<td>1,339,180,127</td>
</tr>
<tr>
<td>2018</td>
<td>1,354,051,854</td>
</tr>
</tbody>
</table>
</body>
</html>输出:

| 属性 | 价值 | 描述 |
|---|---|---|
| align | right left center justify char | 它确定 <thead> 元素内内容的对齐方式。(HTML5 不支持) |
| char | Character | 它指定 <thead> 元素内的内容与字符的对齐方式。(HTML5 不支持) |
| charoff | Number | 它指定内容将与 char 属性指定的字符对齐的字符数。(HTML5 不支持) |
| valign | top middle bottom baseline | 它确定 <thead> 元素内内容的垂直对齐方式。(HTML5 不支持) |
<thead> 标签支持 HTML 中的全局属性。
<thead> 标签支持 HTML 中的 Event 属性。
| 元素 | Chrome | IE | Firefox | Safari | Opera |
|---|---|---|---|---|---|
| <thead> | Yes | Yes | Yes | Yes | Yes |