HTML data tables in an article
If an article contains some data that is best served in table format, html was built just for that purpose. Here is an example of a small table marked up with html:
<table>
<caption>Table 1: Direct and opportunity costs of the IDZ and harbor<a href="#_edn16" id="_ednref16">[16]</a></caption>
<thead>
<tr>
<th>Sector</th>
<th>Income losses<br />(R million/year)</th>
<th>Employment losses<br />(Number of jobs)</th>
</tr>
</thead>
<tr>
<th>Salt production</th>
<td>20</td>
<td>136</td>
</tr>
<tr>
<th>Mariculture</th>
<td>116</td>
<td>875</td>
</tr>
<tr>
<th>Fisheries</th>
<td>not estimated</td>
<td>not estimated</td>
</tr>
<tr>
<th>Agriculture *</th>
<td>510</td>
<td>7500</td>
</tr>
<tr>
<th>Eco-tourism</th>
<td>60</td>
<td>975</td>
</tr>
<tr>
<th>Total</th>
<td>706</td>
<td>9486+</td>
</tr>
<tr>
<td colspan="3" class="tableNote">* Impacts on agricultural production are long term, and therefore of a different nature to the other job losses.</td>
</tr>
</table>
Explanation
- The table starts with the
<table>
tag. - Next comes the
<caption>
, which describes the content of the table - Then there are rows,
<tr></tr>
which contain cells,<td></td>
- There is a special kind of cell, the table header
<th></th>
, to contain row and column headers - If a row contains all table headers, enclose it with
<thead></thead>
- You can also add a table note to the bottom of the table, using a the class
tableNote
, and it can span the columns by using thecolspan
attribute - End the table with the closing
</table>
tag.