Start a table by writing <table>
, and end it by writing </table>
.
Rows are separated by writing <tr>
, and each item in a row starts with <td>
.
Here's an example:
<table>
<td>Row 1, column 1.
<td>Row 1, column 2.
<td>Row 1, column 3.
<td>Row 1, column 4.
<tr>
<td>Row 2, column 1.
<td>Row 2, column 2.
<td>Row 2, column 3.
<td>Row 2, column 4.
<tr>
<td>Row 3, column 1.
<td>Row 3, column 2.
<td>Row 3, column 3.
<td>Row 3, column 4.
<tr>
<td>Row 4, column 1.
<td>Row 4, column 2.
<td>Row 4, column 3.
<td>Row 4, column 4.
</table>
And here's what it looks like:
Row 1, column 1. | Row 1, column 2. | Row 1, column 3. | Row 1, column 4. |
Row 2, column 1. | Row 2, column 2. | Row 2, column 3. | Row 2, column 4. |
Row 3, column 1. | Row 3, column 2. | Row 3, column 3. | Row 3, column 4. |
Row 4, column 1. | Row 4, column 2. | Row 4, column 3. | Row 4, column 4. |
If you want to separate the table's header and body, you can add a split with thead
and tbody
, like this:
<table>
<thead>
<td>column 1.
<td>column 2.
<td>column 3.
<td>column 4.
<tbody>
<td>Row 1, column 1.
<td>Row 1, column 2.
<td>Row 1, column 3.
<td>Row 1, column 4.
<tr>
<td>Row 2, column 1.
<td>Row 2, column 2.
<td>Row 2, column 3.
<td>Row 2, column 4.
</table>
And here's what it looks like:
column 1. | column 2. | column 3. | column 4. | Row 1, column 1. | Row 1, column 2. | Row 1, column 3. | Row 1, column 4. |
Row 2, column 1. | Row 2, column 2. | Row 2, column 3. | Row 2, column 4. |