Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. HTML(超文本标记语言)
  3. HTML 参考
  4. HTML 元素参考
  5. <thead>

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

<thead>

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

* Some parts of this feature may have varying levels of support.

HTML<thead> 元素定义了一组定义表格的列头的行。

尝试一下

<table>  <caption>    Council budget (in £) 2018  </caption>  <thead>    <tr>      <th scope="col">Items</th>      <th scope="col">Expenditure</th>    </tr>  </thead>  <tbody>    <tr>      <th scope="row">Donuts</th>      <td>3,000</td>    </tr>    <tr>      <th scope="row">Stationery</th>      <td>18,000</td>    </tr>  </tbody>  <tfoot>    <tr>      <th scope="row">Totals</th>      <td>21,000</td>    </tr>  </tfoot></table>
thead,tfoot {  background-color: #2c5e77;  color: #fff;}tbody {  background-color: #e4f0f5;}table {  border-collapse: collapse;  border: 2px solid rgb(140 140 140);  font-family: sans-serif;  font-size: 0.8rem;  letter-spacing: 1px;}caption {  caption-side: bottom;  padding: 10px;}th,td {  border: 1px solid rgb(160 160 160);  padding: 8px 10px;}td {  text-align: center;}
内容类别无。
允许内容零或多个<tr>元素。
标签省略开头的标签是强制的。如果<thead> 元素后直接跟<tbody><tfoot>元素,结尾的标签可以被省略。
Permitted parentsA<table> element. The<thead> must appear after any<caption> or<colgroup> element, even implicitly defined, but before any<tbody>,<tfoot> and<tr> element.
Permitted ARIA rolesAny
DOM interfaceHTMLTableSectionElement

属性

This element includes theglobal attributes.

align已弃用

This enumerated attribute specifies how horizontal alignment of each cell content will be handled. Possible values are:

  • left, aligning the content to the left of the cell
  • center, centering the content in the cell
  • right, aligning the content to the right of the cell
  • justify, inserting spaces into the textual content so that the content is justified in the cell
  • char, aligning the textual content on a special character with a minimal offset, defined by thechar andcharoff attributes. If this attribute is not set, theleft value is assumed.

备注:Do not use this attribute as it is obsolete (not supported) in the latest standard.

  • To achieve the same effect as theleft,center,right orjustify values, use the CSStext-align property on it.
  • To achieve the same effect as thechar value, in CSS3, you can use the value of thechar as the value of thetext-align property.
bgcolor非标准

This attribute defines the background color of each cell of the column. It is one of the 6-digit hexadecimal code as defined insRGB, prefixed by a '#'. One of the sixteen predefined color strings may be used.

备注:Do not use this attribute, as it is non-standard and only implemented in some versions of Microsoft Internet Explorer: the<thead> element should be styled usingCSS. To give a similar effect to thebgcolor attribute, use theCSS propertybackground-color, on the relevant<td> or<th> elements.

char已弃用

This attribute is used to set the character to align the cells in a column on. Typical values for this include a period (.) when attempting to align numbers or monetary values. Ifalign is not set tochar, this attribute is ignored.

备注:Do not use this attribute as it is obsolete (and not supported) in the latest standard. To achieve the same effect as thechar, in CSS3, you can use the character set using thechar attribute as the value of thetext-align property.

charoff已弃用

This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by thechar attribute.

备注:Do not use this attribute as it is obsolete (and not supported) in the latest standard.

valign已弃用

This attribute specifies the vertical alignment of the text within each row of cells of the table header. Possible values for this attribute are:

  • baseline, which will put the text as close to the bottom of the cell as it is possible, but align it on thebaseline of the characters instead of the bottom of them. If characters are all of the size, this has the same effect asbottom.
  • bottom, which will put the text as close to the bottom of the cell as it is possible;
  • middle, which will center the text in the cell;
  • top, which will put the text as close to the top of the cell as it is possible.

备注:Do not use this attribute as it is obsolete (and not supported) in the latest standard: instead set the CSSvertical-align property on it.

示例

See<table> for examples on<thead>.

规范

Specification
HTML
# the-thead-element

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp