HTML <th> tag
Examples
A simple HTML form with two header cell and two data cells:
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
try it"
(For more examples, see the bottom of the page)
Browser Support
All major browsers support <th> tag.
Tag definitions and instructions
<Th> tag defines an HTML table header cell.
HTML table, there are two types of cells:
- Header cells - contains header information (created by the <th> element)
- Standard cells - contains data (by the <td> create elements)
<Th> element is typically rendered as bold text and centered.
<Td> element is usually plain text left-aligned text.
Tips and Notes
Tip: If youneed content across multiple rows or columns, use colspan and rowspan attributes!
Differences between HTML 4.01 and HTML5
HTML 5 is no longer some HTML 4.01 attributes support.
Attributes
属性 | 值 | 描述 |
---|---|---|
abbr | text | HTML5 不支持。 规定表头单元格中内容的缩写版本。 |
align | left right center justify char |
HTML5 不支持。 规定表头单元格内容的水平对齐方式。 |
axis | category_name | HTML5 不支持。 对表头单元格进行分类。 |
bgcolor | rgb(x,x,x) #xxxxxx colorname |
HTML5 不支持。HTML 4.01 已废弃。 规定表头单元格的背景颜色。 |
char | character | HTML5 不支持。 规定根据哪个字符来进行内容的对齐。 |
charoff | number | HTML5 不支持。 规定对齐字符的偏移量。 |
colspan | number | 规定表头单元格可横跨的列数。 |
headers | header_id | 规定与表头单元格相关联的一个或多个表头单元格。 |
height | pixels % |
HTML5 不支持。HTML 4.01 已废弃。 规定表头单元格的高度。 |
nowrap | nowrap | HTML5 不支持。HTML 4.01 已废弃。 规定表头单元格中的内容是否折行。 |
rowspan | number | 规定表头单元格可横跨的行数。 |
scope | col colgroup row rowgroup |
规定表头单元格是否是行、列、行组或列组的头部。 |
valign | top middle bottom baseline |
HTML5 不支持。 规定表头单元格内容的垂直排列方式。 |
width | pixels % |
HTML5 不支持。HTML 4.01 已废弃。 规定表头单元格的宽度。 |
Global Properties
<th> tag supports HTML global properties .
Event Properties
<th> tag supports all HTML event properties .
Try - Example
Table title
This example demonstrates how to display table headers.
Empty Cells
This example demonstrates how to use the "& nbsp;" no content processing cell.
Table with headings
This example demonstrates with a title (caption) form.
Tags within the table
This example demonstrates how to display elements inside other elements.
Interbank across columns or table cell
This example demonstrates how to define cross or across columns of a table cell.
related articles
HTML Tutorial: HTML table
HTML DOM Reference Manual: Th objects