Tables

The table HTML element represents a semantically connected pieces of data arranged in the form of rows and columns.

An HTML table is built using the following elements:

  • table - the enclosing table element,

  • tr (table row) - a table row,

  • th (table header) - a header column in a table row,

  • td (table data) - a data column in a table row.

  • thead - an optional element for grouping tr table wide header elements,

  • tbody - an optional element for grouping tr table data elements.

Further, the optional elements are caption (used for table captioning), colgroup (used for column formatting) and tfoot (used for denoting footer content of a table)..

<table>
  <thead>
    <tr>
      <th>Horse</th>
      <th>Witcher</th>
      <th>Coloration</th>
    </tr>
  <thead>
  <tbody>
    <tr>
      <td>Roach</td>
      <td>Geralt</td>
      <td>Brown</td>
    </tr>
    <tr>
      <td>Bucephalus</td>
      <td>Alexander</td>
      <td>Dark Gray</td>
    </tr>
  </tbody>
</table>