Fandom

HTML & CSS Wiki

Th

649pages on
this wiki
Add New Page
Comments0 Share

The semantic HTML <th></th> element defines a table header. It must be placed within a <table>, <thead>, <tbody>, or <tfoot> which contains a <tr> element and may only contain the table header. The end tag may be omitted, if it is immediately followed by another <th> or <td> element or if there are no more data in its parent element.

Attributes

Attribute Value Description
colspan number This attribute contains a non-negative integer value that indicates how many columns the cell extends to. Its default value is 1; if its value is set to 0, it will extend until the end of the <colgroup> the cell belongs to.
headers id This attributes is a list of space-separated strings, each corresponding to the id attribute of the <th> elements that applies to this element.
rowspan number This attribute contains a non-negative integer value that indicates how many rows the cell extends to. Its default value is 1; if its value is set to 0, it will extend until the end of the table section (<thead>, <tbody>, <tfoot>, etc.) the cell belongs to.
scope row
col
rowgroup
colgroup
auto
This enumerated attribute defines the cells that the header defined in this <th> element relates to. It may have the following values:
  • row - Which means that the header relates to all cells in the row that this element belongs to;
  • col - Which means that the header relates to all cells in the column that this element belongs to;
  • rowgroup - Which means that the header relates to all remaining cells in the row that this element belongs to. The remaining cells are either those to the right of this element, or to his left depending of the value of dir attribute defined in the <table> element;
  • colgroup - Which means that the header relates to all remaining cells in the column that this element belongs to;
  • auto - The relation of the header is automatically assigned.


Global attributes

See Global HTML Attributes.


HTML example:

<table>
<tr>
<th>Numbers</th>
<td>1</td>
<td>2</td>
</tr>
</table>

External links

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.