HTML Essentials

Tables

Represent relationships in rows and columns.

Tables are for structured data. Header cells label the meaning of each row or column.

Important definitions

Table row
A horizontal group represented by tr.
Header cell
A th that labels data.

Syntax

Use this general pattern as a reference:

HTML
<table><tr><th>Name</th></tr><tr><td>Ada</td></tr></table>

Examples

Score table

EXAMPLE 1
<table><tr><th>Player</th><th>Score</th></tr><tr><td>Sam</td><td>8</td></tr></table>
ResultA two-column score table
Try it yourself

Expected output

A table with Course and Level columns.

Note

Do not use tables to arrange page layout.

Tip

Add a caption when the table purpose is not obvious.

Common mistakes

  • Missing header cells.
  • Using tables for visual columns.