KodingKaro
HTML · Beginner · Tables

Table rows, cells, captions, and headers

A data table is useful when readers need to compare values by both row and column.

✓ What you will learn in this topic

  • Explain the purpose of Table rows, cells, captions, and headers in a real HTML document.
  • Choose and apply the elements shown in both examples.
  • Recognize the specific mistake described in this lesson.

Concept explanation

Table contains the data grid. Tr creates a row, td contains a data value, and th identifies a header. Caption names the table so people know what it summarizes. Scope=\"col\" associates a header with a column; scope=\"row\" associates it with a row. A table should preserve meaningful relationships even when read without its visual grid.

Syntax

Use caption, then rows of th and td cells; add scope to simple row or column headers.

Example 1: a small page

The caption names the data, and the first row labels the two columns.

<table>
  <caption>Workshop seats</caption>
  <tr><th scope=\"col\">Session</th><th scope=\"col\">Seats</th></tr>
  <tr><td>Morning</td><td>12</td></tr>
</table>

Expected result: A titled table shows Morning and its value of 12 beneath the appropriate headers.

Example 2: a practical page

The row groups organize headers and data; each day is also a row header.

<table>
  <caption>Club room schedule</caption>
  <thead><tr><th scope=\"col\">Day</th><th scope=\"col\">Room</th></tr></thead>
  <tbody><tr><th scope=\"row\">Friday</th><td>Studio 2</td></tr><tr><th scope=\"row\">Saturday</th><td>Hall A</td></tr></tbody>
</table>

Expected result: A captioned schedule table has Day and Room columns and two clearly labeled day rows.

Common mistakes

Do not use a table to arrange page layout; reserve tables for genuinely tabular data.

Best practices

Give data tables a caption and use th with scope so row and column relationships are clear.

Practice exercise

Create a weekly class timetable with a caption, two column headers, three rows, and a row header for each class.

Lesson summary

  • Tables organize related data; captions and scoped headers explain its rows and columns.
  • Give data tables a caption and use th with scope so row and column relationships are clear.

Knowledge check

Which element names a data table for its readers?

Show the explanation

Caption provides the table’s visible title and helps people identify its subject.

Practical example

html
<table>
  <caption>Workshop seats</caption>
  <tr><th scope=\"col\">Session</th><th scope=\"col\">Seats</th></tr>
  <tr><td>Morning</td><td>12</td></tr>
</table>

Expected result:

A titled table shows Morning and its value of 12 beneath the appropriate headers.

Hands-on practice task

Create a weekly class timetable with a caption, two column headers, three rows, and a row header for each class.

In this section

Other lessons in Tables

Broaden your knowledge

Related learning topics