Tables
Tables are often misused for layout; they should of course only be used for tabular data.
<table>
<caption>
Correlation of attendance to final grade
</caption>
<thead>
<tr>
<th>Name</th>
<th>Attendance</th>
<th>Grade</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3">Survey conducted for the past 30 years!</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Joe Blogs</td>
<td>100%</td>
<td>First</td>
</tr>
<tr>
<td>Fred Busybud</td>
<td>50%</td>
<td>third</td>
</tr>
<tr>
<td colspan="2">Span across … two columns</td>
<td>column 3</td>
</tr>
</tbody>
</table>
Name | Attendance | Grade |
---|---|---|
Survey conducted for the past 30 years! | ||
Joe Blogs | 100% | First |
Fred Busybud | 50% | third |
Span across … TWO columns! | column 3 |
-
Note the anatomy of a table includes a
thead
,tfoot
andtbody
. -
Tables are defined a row at a time where
tr
is a table row andtd
a table column! - The table above defines rows with three columns. Note columns can be combined with the attribute,
colspan
.
Exercise – Tables
- In the portfolio wd folder, create a tables.html file.
- Insert the above table into the tables.html file.
- Validate the tables.html file.