19. Data tables

<table> </table>
Table label.
<thead> </thead>
Label the head of a table. It is in the first row of a table.
<tr> </tr>
Label a row within a table.
<th> </th>
Label each of the elements of a table header.
<tbody> </tbody>
Body of a table, where the contents of the table are located. Allows you to separate the header from the contents.
<td> </td>
Label an element of a table. It must be within a row.
<!-- comment -->
Tag to include a comment within the HTML code. Comments are used to explain the HTML code but will not be displayed on the web page.

Simple table code

_images/html-table1-html.png

Data table template without header.

<table border="1">
   <tbody>
      <tr>
         <td>Uno</td>  <td> 1 </td>
      </tr>
      <tr>
         <td>Dos</td>  <td> 2 </td>
      </tr>
   </tbody>
</table>

Result

_images/html-table1-web.png

Code of a table with header

_images/html-table2-html.png

Data table template with header.

<table border="1">
   <thead>
      <tr>
         <th>Columna 1</th>  <th>Columna 2</th>
      </tr>
   </thead>

   <tbody>
      <tr>
         <td>Uno</td>  <td> 1 </td>
      </tr>
      <tr>
         <td>Dos</td>  <td> 2 </td>
      </tr>
   </tbody>
</table>

Result

_images/html-table2-web.png