🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·
🌐 Web (HTML & CSS)

Tables

Tables organize data in rows and columns. Use <table>, <tr> (row), <th> (header cell), <td> (data cell). Add <thead> and <tbody> for structure.

3 min 10 XP Lesson 5 of 26
Tables
🌐

Appy Says…

Tables get a bad reputation (people used them for page layouts in 2004 — don't do that). But for actual tabular data — leaderboards, schedules, comparison charts, spreadsheets — <table> is exactly the right tool.

📖

What are HTML Tables?

An HTML table displays data in rows and columns. It's made of nested elements: the table, rows, header cells, and data cells.

  • <table> — the container
  • <thead> — header section; <tbody> — data rows; <tfoot> — footer
  • <tr> — a row
  • <th> — header cell (bold, centred by default)
  • <td> — data cell
  • colspan="2" — cell spans 2 columns
  • rowspan="3" — cell spans 3 rows
  • scope="col" on <th> — improves accessibility
🎮

Think of it like a Minecraft crafting grid

A 3×3 crafting grid is a table — rows and columns of slots, each holding an item. HTML tables work the same: rows go side to side, columns stack vertically, and each cell holds content.

⚙️

How It Works

  • 1. <table> opens the table
  • 2. <thead><tr><th>Name</th><th>Score</th></tr></thead> — header row
  • 3. <tbody> contains the data rows
  • 4. Each <tr> is a row; <td> cells fill each column position
  • 5. Columns are implicit — defined by how many cells are in each row
  • 6. Style with CSS: border-collapse: collapse merges borders cleanly
🌍

Real-World Examples

  • A game leaderboard: columns for Rank, Player, Score, Date
  • A class timetable: rows for time slots, columns for days
  • A price comparison table: rows for features, columns for plans
  • Sports results: teams, points, wins, losses per row
💡

Key Facts

  • Tables are NOT for page layout — that's what CSS Grid and Flexbox are for
  • <th scope="col"> tells screen readers whether a header applies to a column or row
  • CSS table-layout: fixed makes column widths equal regardless of content
  • Responsive tables often use overflow-x: auto on a wrapper div to scroll horizontally on mobile
⚠️

Watch Out!

Don't use tables for page layout — it was a 1990s hack. It breaks responsiveness, harms accessibility, and is considered terrible practice today. Use CSS Grid or Flexbox for layout. Tables are only for tabular data.

📌

Remember

Tables = data that belongs in rows and columns (like a spreadsheet). Not for page layouts. Use <thead>, <tbody>, and <th scope> for proper semantics.

What You Learned

  • Tables: <table> → <thead>/<tbody> → <tr> → <th>/<td>
  • Use scope on headers for accessibility; colspan/rowspan to merge cells
  • Unlocks: leaderboards, schedules, pricing comparisons, any data with rows and columns

Key Facts

  • Tables are NOT for page layout — that's what CSS Grid and Flexbox are for
  • <th scope="col"> tells screen readers whether a header applies to a column or row
  • CSS table-layout: fixed makes column widths equal regardless of content
  • Responsive tables often use overflow-x: auto on a wrapper div to scroll horizontally on mobile

Real-World Examples

• A game leaderboard: columns for Rank, Player, Score, Date • A class timetable: rows for time slots, columns for days • A price comparison table: rows for features, columns for plans • Sports results: teams, points, wins, losses per row

Remember

Tables = data that belongs in rows and columns (like a spreadsheet). Not for page layouts. Use <thead>, <tbody>, and <th scope> for proper semantics.

Quick Quiz

1 / 2

What is <td>?