Warning:
This wiki has been archived and is now read-only.

Elements/td

From HTML Wiki
Jump to: navigation, search

<td>

The <td> element represents a data cell in a table.

HTML Attributes

  • colspan = valid non-negative integer
    This attribute gives the number of columns respectively that the cell is to span. [Example B]
  • rowspan = valid non-negative integer
    This attribute gives the number of rows respectively that the cell is to span.
  • 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]


See also global attributes.


Examples

Example A

[try it]

<table>
  <caption>
    <p>table 1. Sample table</p>
  </caption>
  <tr>
    <td>1</td>
    <td>2</td>
  </tr>
  <tr>
    <td>3</td>
    <td>4</td>
  </tr>
</table>

Example B

[try it]:

<table>
  <caption>
    <p>table 1. Sample table</p>
  </caption>
  <tr>
    <td>1</td>
    <td>2</td>
  </tr>
  <tr>
    <td colspan="2">3</td>
  </tr>
</table>

Example C

Use case of the headers attribute [try it]:

<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>

HTML Reference

The HTML5 specification defines the <td> element in 4.9.9 The td element.