HTML <thead> 標籤


實例

帶有 <thead>、<tfoot> 和 <tbody> 元素的 HTML 表格:

<table border="1"> <thead> <tr> <th>Month</th> <th>Savings</th> </tr> </thead> <tfoot> <tr> <td>Sum</td> <td>$180</td> </tr> </tfoot> <tbody> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </tbody> </table>


流覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流流覽器都支持 <thead> 標籤。


標籤定義及使用說明

<thead> 標籤用於組合 HTML 表格的表頭內容。

<thead> 元素應該與 <tbody><tfoot> 元素結合起來使用,用來規定表格的各個部分(表頭、主體、頁腳)。

通過使用這些元素,使流覽器有能力支持獨立於表格表頭和表格頁腳的表格主體滾動。當包含多個頁面的長的表格被列印時,表格的表頭和頁腳可被列印在包含表格數據的每張頁面上。

<thead> 標籤必須被用在以下情境中:作為 <table> 元素的子元素,出現在 <caption>、<colgroup> 元素之後,<tbody>、 <tfoot> 和 <tr> 元素之前。


提示和注釋

注釋:<thead> 元素內部必須包含一個或者多個 <tr> 標籤。

提示:<thead>、<tbody> 和 <tfoot> 元素默認不會影響表格的佈局。不過,您可以使用 CSS 來為這些元素定義樣式,從而改變表格的外觀。


HTML 4.01 與 HTML5之間的差異

在 HTML 5 中,不再支持 HTML 4.01 中 <thead> 標籤的任何屬性。


屬性

屬性 描述
align right
left
center
justify
char
HTML5 不支持。定義 <thead> 元素中內容的對齊方式。
char character HTML5 不支持。規定 <thead> 元素中內容根據哪個字元來對進行文本對齊。
charoff number HTML5 不支持。規定 <thead> 元素中內容的第一個對齊字元的偏移量。
valign top
middle
bottom
baseline
HTML5 不支持。規定 <thead> 元素中內容的垂直對齊方式。


全局屬性

<thead> 標籤支持 HTML 的全局屬性


事件屬性

<thead> 標籤支持 HTML 的事件屬性