HTML · Unit 3: Tables, forms and a profile card · Lesson 1 of 5
Tables
Tables are for data that has rows and columns, like a timetable.
Opens this lesson in Code Academy. Lessons open one after another, and each unit opens when you pass the checkpoint quiz before it (you can take a checkpoint early to skip ahead). If this lesson is not open yet, the button shows you its unit on your map.
The idea
Tables are for data that has rows and columns, like a timetable. A <table> holds rows (<tr>), and each row holds cells: <th> for headings and <td> for data.
Put a heading row first so every column is labelled. Screen readers announce the heading as they read each cell.
Do not use tables to lay out a page. That is the job of CSS, which you will learn soon.
Worked example
HTML
<table>
<tr>
<th>Day</th>
<th>Opens</th>
</tr>
<tr>
<td>Monday</td>
<td>9am</td>
</tr>
</table>
Key terms
- Table
- Rows (<tr>) of heading cells (<th>) and data cells (<td>), for data in rows and columns.
Practise it in Code Academy
It has 4 exercises (multiple choice, fill in the blank, fix the broken code and write code from a prompt) and takes about 7 minutes. Every answer is checked as you go, and feedback names the exact mistake. Hints and the solution are there if you get stuck.
Every lesson is free: no ads, no lives and no paywall.