Skip to main content

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. 1

    Build a pricing table

    easy15 min

    Build 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. 2

    Caption the table

    easy15 min

    Add 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. 3

    Merge header cells with colspan

    easy15 min

    The 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. 4

    Add a table footer

    easy15 min

    Add 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. 5

    Label a row header

    easy15 min

    In 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. 6

    Build a basic table

    easy10 min

    Add a table with one row of two cells.

  7. 7

    Add header cells

    easy10 min

    Use th for the header row.

  8. 8

    Add a caption

    easy10 min

    Give the table a caption saying "Team".

  9. 9

    Group the head and body

    easy10 min

    Use thead and tbody to structure the table.

  10. 10

    Span two columns

    medium10 min

    Add a cell that spans two columns.

Find the bug(10)

  1. 1

    Fix the headers written as data cells

    easy15 min

    This 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. 2

    Fix the wrong colspan

    easy15 min

    This 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. 3

    Fix the missing scope attribute

    easy15 min

    These column headers are missing scope="col", which screen readers rely on to associate each header with its column. Add it to both.

  4. 4

    Fix the missing tbody

    easy15 min

    This 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. 5

    Fix the misplaced caption

    easy15 min

    This 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. 6

    Fix the table with no rows

    easy8 min

    The table element is empty, so there is nothing to show.

  7. 7

    Fix the header row using td

    easy8 min

    The header row should use th, not td.

  8. 8

    Fix the caption placed outside

    easy8 min

    The caption must be inside the table.

  9. 9

    Fix the divs pretending to be a table

    easy8 min

    Tabular data should use a real table.

  10. 10

    Fix the wrong span attribute

    easy8 min

    Column 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