This page is Not Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

th

Summary

The th tag defines a header cell in an HTML table.

Overview Table

DOM Interface
HTMLTableHeaderCellElement

Attributes

  • colspan = valid non-negative integer
    This attribute gives the number of columns respectively that the cell is to span.
  • rowspan = valid non-negative integer
    This attribute gives the number of rows respectively that the cell is to span. [Example B]
  • headers = unordered set of unique space-separated tokens
    The value of this attribute must have the value of an id attribute of the th element that is targeted. [Example C]
  • scope = row/ col/ rowgroup/ colgroup
    The scope attribute specifies the cell which the influence of headding cell reaches. [Example D]
    • row
      The header cell applies to some of the subsequent cells in the same row(s).
    • col
      The header cell applies to some of the subsequent cells in the same column(s).
    • rowgroup
      The header cell applies to all the remaining cells in the row group. A th element’s scope attribute must not be in the row group state if the element is not anchored in a row group.
    • colgroup
      The header cell applies to all the remaining cells in the column group. A th element’s scope attribute must not be in the column group state if the element is not anchored in a column group.

Examples

This example uses the table, td, th, and tr.

<table>
    <tr>
      <th>
        This text is in the th
      </th>
    </tr>
    <tr>
      <td>
        This text is in the tbody.
      </td>
    </tr>
</table>

A table cell referring to the table header

<table>
  <caption>
    <p>table 1. List of HTML elements</p>
  </caption>
  <thead>
    <tr>
      <th id="c1">Number</th>
      <th id="c2">element</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td headers="c1">4.1.1</td>
      <td headers="c2">html</td>
    </tr>
    <tr>
      <td headers="c1">4.2.1</td>
      <td headers="c2">head</td>
    </tr>
  </tbody>
</table>
<table>
  <caption>
    <p>table 1. List of HTML elements</p>
  </caption>
  <thead>
    <tr>
      <th scope="row">Number</th>
      <th scope="row">element</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>4.1.1</td>
      <td>html</td>
    </tr>
    <tr>
      <td>4.2.1</td>
      <td>head</td>
    </tr>
  </tbody>
</table>

Related specifications

HTML 5.1
W3C Working Draft
HTML 5
W3C Recommendation
HTML 4.01
W3C Recommendation

See also

Related articles

HTML

Tables

Attributions