Back to subject
HTML5/HTML Tables

Read a Small Table

Practical lesson

Let's build a small table and read its structure from top to bottom.

- <table> is the outer container for the table. - <caption> gives the table a visible description or title when one is useful. - <thead> groups the header rows. - <th> represents a header cell, such as Name or Age. - <tbody> groups the main data rows. - <td> represents an ordinary data cell. - Each <tr> creates one table row. - Keep the number and meaning of cells consistent so the rows line up correctly. - For accessible tables, use clear headers and consider the scope attribute on header cells. - colspan and rowspan can make one cell span multiple columns or rows, but use them only when the data really has that relationship.

A table is for related data that naturally fits rows and columns. It is not a general page-layout tool.

Try it yourself
Code

Starter example

Code
<table>
  <tr>
    <th>Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Ali</td>
    <td>10</td>
  </tr>
</table>
Live preview