HTML.lt;th> tags
The label represents the header portion of the HTML table, and the contents of the label are shown in bold, see the following example:A simple HTML table with two header cells and two data cells:
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
Try it out . . .
(See bottom of page for more examples)
Browser support
All major browsers support the hashtag.
Label definition and instructions for use
Labels define header cells in HTML tables.
HTML tables have two cell types:
- Header Cell - Contains header information (created by the element of the .lt;th-gt; element)
- Standard Cells - Contains data (created by the element of slt;td?gt;
The text in the element is usually bold and centered.
The text in the element is usually normal left-aligned text.
Tips and comments
Tip: If you need to span content across multiple rows or columns, use the colspan and rowspan properties!
The difference between HTML 4.01 and HTML5
Some properties in HTML 4.01 are no longer supported in HTML 5.
Property
Attributes | value | describe |
---|---|---|
abbr | text | HTML5 does not support. Specify the abbreviation version of the content in the head unit cell. |
align |
left
right center justify char |
HTML5 does not support. The horizontal alignment of the content of the head unit cell is specified. |
axis | category_name | HTML5 does not support. Classify the header cell. |
bgcolor |
rgb(x,x,x)
#xxxxxx colorname |
HTML5 does not support.HTML 4.01 has been discarded. The background color of the head unit cell is specified. |
char | character | HTML5 does not support. The content is arranged to be aligned based on which character. |
charoff | number | HTML5 does not support. Specifies the offset of aligned characters. |
colspan | number | The number of columns can be specified in the head unit. |
headers | header_id | The one or more head cells associated with the header unit cell is specified. |
height |
pixels
% |
HTML5 does not support.HTML 4.01 has been discarded. Specifies the height of the head unit cell. |
nowrap | nowrap | HTML5 does not support.HTML 4.01 has been discarded. Specifies whether the content in the head unit cell is folded. |
rowspan | number | The number of rows that the head unit can be across the head unit. |
scope |
col
colgroup row rowgroup |
Specify whether the head unit cell is a line, column, group, or group group. |
valign |
top
middle bottom baseline |
HTML5 does not support. Specifies the vertical arrangement of the head unit cell content. |
width |
pixels
% |
HTML5 does not support.HTML 4.01 has been discarded. Specifies the width of the head unit. |
Global properties
Labels support the global properties of HTML.
The event property
The label supports all HTML event properties.
Try it - instance
The title in the table
This example shows how to display the table title.
Empty cell
This example shows how to use to work with cells without content.
Table with title
This example shows a table with a title.
The label in the table
This example shows how to display elements within other elements.
Table cells that span rows or columns
This example shows how to define table cells that span rows or columns.
Related articles
HTML tutorial: HTML tables
HTML DOM Reference Manual: Th Object