MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey-2018-1

这篇翻译不完整。请帮忙从英语翻译这篇文章

HTML <th> 元素定义表格内的表头单元格。这组表格的 The exact nature of this group is defined by the scope and headers attributes.

内容范畴
允许内容
流内容(除header、footer、分解内容或标题内容)
遗漏标签 强制需要开始标签,如果其后是<th><td> ,或者其后没有其他数据内容在其父元素内,则结束标签可以省略。
允许的父级元素  <tr> 元素
元素类型 Any
DOM接口 HTMLTableHeaderCellElement

属性

该元素包含 全局属性

abbr in HTML5
这个属性包含一个简单的内容介绍。例如一个用户的一次演讲中可能存在的描述信息。
使用提醒 : 不要使用这个属性,因为它已经在最新标准中过时。你可以把简单描述内容放置于单元格内,把较长的描述内容放到title属性内。
align in HTML 4, in HTML5
这个枚举属性指定单元格内容的水平对齐方式。可能的值有:
  • left: 单元格内容左对齐
  • center: 单元格内容居中
  • right:  单元格内容右对齐
  • justify (仅文字内容): 内容拉伸以覆盖单元格
  • char (仅文字内容): 内容相对<th>标签中的某个字符对齐(默认值是页面语言的小数点字符)。该字符由charcharoff 属性定义。

对齐方式的默认值是 left.

使用提示: 不要使用这个属性,因为它已经在最新标准中过时。
  •  left, center, rightjustify 这些对齐效果,应该使用CSS的text-align 来实现。
  •  char 的对齐效果使用CSS的 text-align 实现, char亦同.  未实现 in CSS3.
axis in HTML5
This attribute contains a list of space-separated strings. Each string is the id of a group of cells that this header applies to.
使用提示: 不要使用这个属性,因为它已经在最新标准中过时。应该使用 scope 属性代替。
bgcolor
This attribute defines the background color of each cell in a column. It consists of a 6-digit hexadecimal code as defined in sRGB and is prefixed by '#'. This attribute may be used with one of sixteen predefined color strings:
  black = "#000000"   green = "#008000"
  silver = "#C0C0C0"   lime = "#00FF00"
  gray = "#808080"   olive = "#808000"
  white = "#FFFFFF"   yellow = "#FFFF00"
  maroon = "#800000"   navy = "#000080"
  red = "#FF0000"   blue = "#0000FF"
  purple = "#800080"   teal = "#008080"
  fuchsia = "#FF00FF"   aqua = "#00FFFF"
使用提示: 不要使用这个属性,它不是标准属性,仅 在Microsoft Internet Explorer支持: The <th> element should be styled using CSS. To create a similar effec use the background-color property in CSS.
char in HTML 4, in HTML5
The content of a column is aligned to a character in the <th> element. Typical values include a period (.) to align numbers or monetary values. If align is not set to char, this attribute is ignored.
使用提示: 不要使用这个属性,因为它已经在最新标准中过时。To achieve the same effect , you can specify the character as the first value of the text-align property,  未实现 in CSS3.
charoff in HTML 4, in HTML5
This attribute is used to shift column data to the right of the character specified by the char attribute. Its value specifies the length of this shift.
使用提示: 不要使用这个属性,因为它已经在最新标准中过时。
colspan
This attribute contains a positive integer value that indicates over how many columns a cell is extended. Its default value is 1. If its value is set to 0, the cell is extended to the last element of the <colgroup>. Values higher than 1000 are clipped down to 1000.
headers
This attribute contains a list of space-separated strings, each corresponding to the id attributes of other <th> elements that relate to this element.
rowspan
This attribute contains a positive integer value that indicates over how many rows a cells is extended. Its default value is 1. If its value is set to 0, the cell is extended to the last element of the table sections (<thead>, <tbody> or <tfoot>). Values higher than 65534 are clipped down to 65534.
scope
This enumerated attribute defines the cells that the header (defined in the <th>) element relates to. It may have the following values:
  • row:  The header relates to all cells of the row it belongs to.
  • col: The header relates to all cells of the column it belongs to.
  • rowgroup: The header belongs to a rowgroup and relates to all of its cells. These cells can be placed to the right or the left of the header, depending on the value of the dir attribute in the <table> element.
  • colgroup: The header belongs to a colgroup and relates to all of its cells.
  • auto
valign in HTML 4, in HTML5
This attribute specifies how a text is vertically aligned inside a cell. Possible values for this attribute are:
  • baseline: Positions the text near the bottom of the cell and aligns it with the baseline of the characters instead of the bottom. If characters don't descend below the baseline, the baseline value achieves the same effect as bottom.
  • bottom: Positions the text near the bottom of the cell.
  • middle: Centers the text in the cell.
  • and top: Positions the text near the top of the cell.
不要使用这个属性,因为它已经在最新标准中过时。使用CSS vertical-align特性代替。
width in HTML 4.01
This attribute is used to define a recommended cell width.  Additional space can be added with the cellspacing and cellpadding properties and the width of the <col> element can also create extra width. But, if a column's width is too narrow to show a particular cell properly, it will be widened when displayed.
不要使用这个属性,因为它已经在最新标准中过时。使用CSS width特性代替。

示例

参考 <table><th>的示例内容。

规范

规范 状态 备注
HTML Living Standard
th element
Living Standard  
HTML5
th element
Recommendation  

浏览器兼容性

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support1 Yes1 Yes Yes Yes
abbr1 Yes1 Yes Yes Yes
align ? Yes No1 Yes ? ?
axis1 Yes1 Yes Yes Yes
bgcolor ? No No Yes ? ?
char ? Yes No2 Yes ? ?
charoff ? Yes No2 Yes ? ?
colspan1 Yes1 Yes Yes Yes
headers1 Yes1 Yes Yes Yes
rowspan1 Yes1 Yes Yes Yes
scope1 Yes1 Yes Yes Yes
valign ? Yes No1 Yes ? ?
width1 Yes1 Yes Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic support Yes Yes Yes4 Yes Yes Yes
abbr Yes Yes Yes4 Yes Yes Yes
align ? ? Yes No1 Yes ? ?
axis Yes Yes Yes4 Yes Yes Yes
bgcolor ? ? No No Yes ? ?
char ? ? Yes No2 Yes ? ?
charoff ? ? Yes No2 Yes ? ?
colspan Yes Yes Yes4 Yes Yes Yes
headers Yes Yes Yes4 Yes Yes Yes
rowspan Yes Yes Yes4 Yes Yes Yes
scope Yes Yes Yes4 Yes Yes Yes
valign ? ? Yes No1 Yes ? ?
width Yes Yes Yes4 Yes Yes Yes

1. See bug 915

2. See bug 2212

参阅

文档标签和贡献者

标签: 
 此页面的贡献者: levinweb
 最后编辑者: levinweb,