HTML Tables — exercises and bug fixes
10 hands-on exercises and 10 find-the-bug challenges for the HTML Tables lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(10)
- 1
Build a pricing table
easy15 minBuild a table with a <thead> row of column headers (Plan, Price, Storage) and a <tbody> with at least two plan rows. Use <th> for the header cells.
- Add a <table> element.
- Add three header cells in thead.
- Add at least two rows in tbody.
- 2
Caption the table
easy15 minAdd a <caption> reading "Q1 sales by region" as the table's first child.
- Add a <caption> as a direct child of the table.
- The caption should read "Q1 sales by region".
- 3
Merge header cells with colspan
easy15 minThe header row needs a "Quarterly Totals" cell that spans across all 3 data columns. Give that <th> colspan="3".
- Add a header cell reading "Quarterly Totals".
- Give the header cell colspan="3".
- 4
Add a table footer
easy15 minAdd a <tfoot> row with a "Total" label and the value "$310" alongside the existing thead and tbody.
- Add a <tfoot> to the table.
- The footer row should include the label "Total".
- 5
Label a row header
easy15 minIn this player stats table, the first cell of each row names the player and should be a row header. Change those cells to <th scope="row">.
- Turn the player name cell into a <th scope="row">.
- The row header should still say "Amara".
- 6
Build a basic table
easy10 minAdd a table with one row of two cells.
- 7
Add header cells
easy10 minUse th for the header row.
- 8
Add a caption
easy10 minGive the table a caption saying "Team".
- 9
Group the head and body
easy10 minUse thead and tbody to structure the table.
- 10
Span two columns
medium10 minAdd a cell that spans two columns.
Find the bug(10)
- 1
Fix the headers written as data cells
easy15 minThis table's column headers were written with <td> instead of <th>, so screen readers can't announce them as headers. Fix the header row.
- 2
Fix the wrong colspan
easy15 minThis 3-column table's title row uses colspan="2", so it doesn't stretch across the last column. Fix the colspan to span all 3 columns.
- 3
Fix the missing scope attribute
easy15 minThese column headers are missing scope="col", which screen readers rely on to associate each header with its column. Add it to both.
- 4
Fix the missing tbody
easy15 minThis table's data rows sit directly inside <table> with no <tbody> wrapper. Wrap them in a <tbody> so the table has a proper row-group structure.
- Add a <tbody> wrapping the data row.
- Keep the row inside tbody.
- 5
Fix the misplaced caption
easy15 minThis table's title is a <p> placed above the table. Turn it into a proper <caption> as the table's first child instead.
- Add a <caption> as the table's first child.
- The caption should read "Team roster".
- 6
Fix the table with no rows
easy8 minThe table element is empty, so there is nothing to show.
- 7
Fix the header row using td
easy8 minThe header row should use th, not td.
- 8
Fix the caption placed outside
easy8 minThe caption must be inside the table.
- 9
Fix the divs pretending to be a table
easy8 minTabular data should use a real table.
- 10
Fix the wrong span attribute
easy8 minColumn spanning uses colspan, not span.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace