</> ConvertAtlas Developer Tools
Building Content Lesson 7 Beginner 11 min

Tables

Display rows and columns of data with proper, accessible table markup.

Tables display data in rows and columns — schedules, prices, comparisons, statistics. They have a few moving parts, but the pattern is logical once you see it.

The basic table

A table is built from rows, and each row contains cells. Use <code>&lt;table&gt;</code> for the table, <code>&lt;tr&gt;</code> for each table row, <code>&lt;th&gt;</code> for header cells, and <code>&lt;td&gt;</code> for data cells.

HTML · editable
A basic table — try adding a row.

Structuring with thead, tbody and caption

For clarity and accessibility, group the header row in <code>&lt;thead&gt;</code> and the data rows in <code>&lt;tbody&gt;</code>. A <code>&lt;caption&gt;</code> right after the opening table tag gives the table a title that screen readers announce.

HTML · editable

Spanning cells

A cell can stretch across multiple columns with <code>colspan</code>, or down multiple rows with <code>rowspan</code>. This is how you build more complex layouts like merged headers.

HTML · editable
colspan merges two columns into one header.
Tables are for dataTables are for tabular data, not for page layout. In the early web people built whole layouts with tables — today that is done with CSS. Use a table only when your content really is a grid of data.
Try it yourself: a timetable

Build a small timetable in the editable box: a caption, a thead with day and subject columns, and a tbody with three rows of data. Bonus: use colspan on a header.

Quick quiz

1. What element is a table row?

2. What is the difference between <th> and <td>?

3. Which attribute makes a cell span two columns?

4. When should you use a table?

Key takeaways
  • Tables use <table>, rows <tr>, header cells <th> and data cells <td>.
  • Group with <thead>/<tbody> and title with <caption> for accessibility.
  • Use colspan and rowspan to span columns or rows.
  • Use tables for data, never for page layout.