HTML
<th>
element
defines a cell as header of a group of table cells. The exact nature of this group is defined by the
scope
and
headers
属性。
| 内容类别 | None. |
|---|---|
| 准许内容 | 流内容 , but with no header, footer, sectioning content, or heading content descendants. |
| Tag omission |
The start tag is mandatory.
The end tag may be omitted, if it is immediately followed by a
<th>
or
<td>
element or if there are no more data in its parent element.
|
| Permitted parents |
A
<tr>
元素。
|
| Implicit ARIA role |
columnheader
or
rowheader
|
| Permitted ARIA roles | 任何 |
| DOM 接口 |
HTMLTableHeaderCellElement
|
此元素包括 全局属性 .
abbr
This attribute contains a short abbreviated description of the cell's content. Some user-agents, such as speech readers, may present this description before the content itself.
colspan
1
. Values higher than 1000 will be considered as incorrect and will be set to the default value (1).
headers
<th>
elements that apply to this element.
rowspan
1
; if its value is set to
0
, it extends until the end of the table section (
<thead>
,
<tbody>
,
<tfoot>
, even if implicitly defined), that the cell belongs to. Values higher than 65534 are clipped down to 65534.
scope
<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>
元素。
colgroup
: The header belongs to a colgroup and relates to all of its cells.
auto
The default value when this attribute is not specified is
auto
.
align
Obsolete since
HTML5
left
: The content is aligned to the left of the cell.
center
: The content is centered in the cell.
right
: The content is aligned to the right of the cell.
justify
(with text only): The content is stretched out inside the cell so that it covers its entire width.
char
(with text only): The content is aligned to a character inside the
<th>
element with minimal offset. This character is defined by the
char
and
charoff
属性。
The default value when this attribute is not specified is
left
.
left
,
center
,
right
or
justify
values, apply the CSS
text-align
property to the element.
char
value, give the
text-align
property the same value you would use for the
char
.
Unimplemented
in CSS3.
axis
Obsolete since
HTML5
id
of a group of cells that this header applies to.
注意:
Do not use this attribute as it is obsolete in the latest standard: use the
scope
attribute instead.
bgcolor
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"
|
<th>
element should be styled using
CSS
. To create a similar effect use the
background-color
特性在
CSS
代替。
char
Obsolete since
HTML5
align
is not set to
char
, this attribute is ignored.
注意:
Do not use this attribute as it is obsolete in the latest standard. To achieve the same effect, you can specify the character as the first value of the
text-align
property,
Unimplemented
in CSS3.
charoff
Obsolete since
HTML5
height
Deprecated since
HTML4
,
Obsolete since
HTML5
height
特性代替。
valign
Obsolete since
HTML5
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.
top
: Positions the text near the top of the cell.
vertical-align
特性代替。
width
Deprecated since
HTML4
,
Obsolete since
HTML5
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.
注意:
Do not use this attribute as it is obsolete in the latest standard: use the CSS
width
特性代替。
见
<table>
for examples on
<th>
.
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'th element' in that specification. |
实时标准 | |
|
HTML5
The definition of 'th element' in that specification. |
推荐 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
th
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
abbr
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
align
弃用
|
Chrome ? | Edge 完整支持 12 |
Firefox
不支持
No
注意事项
|
IE 完整支持 Yes | Opera ? | Safari ? | WebView Android ? | Chrome Android ? |
Firefox Android
不支持
No
注意事项
|
Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
axis
弃用
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
bgcolor
弃用
|
Chrome ? | Edge ? | Firefox 不支持 No | IE 完整支持 Yes | Opera ? | Safari ? | WebView Android ? | Chrome Android ? | Firefox Android 不支持 No | Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
char
弃用
|
Chrome ? | Edge 完整支持 12 |
Firefox
不支持
No
注意事项
|
IE 完整支持 Yes | Opera ? | Safari ? | WebView Android ? | Chrome Android ? |
Firefox Android
不支持
No
注意事项
|
Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
charoff
弃用
|
Chrome ? | Edge 完整支持 12 |
Firefox
不支持
No
注意事项
|
IE 完整支持 Yes | Opera ? | Safari ? | WebView Android ? | Chrome Android ? |
Firefox Android
不支持
No
注意事项
|
Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
colspan
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
headers
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
rowspan
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
scope
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
valign
弃用
|
Chrome ? | Edge 完整支持 12 |
Firefox
不支持
No
注意事项
|
IE 完整支持 Yes | Opera ? | Safari ? | WebView Android ? | Chrome Android ? |
Firefox Android
不支持
No
注意事项
|
Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
width
弃用
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
完整支持
不支持
兼容性未知
弃用。不要用于新网站。
见实现注意事项。
<caption>
,
<col>
,
<colgroup>
,
<table>
,
<tbody>
,
<td>
,
<tfoot>
,
<thead>
,
<tr>
.