A webpage should make sense even when someone cannot see its colors, pictures, or layout.
What You Need to Know
Caption explains what the table is about. Header cells identify the meanings of rows and columns. Together, they let someone explore data without having to remember where every number belongs.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<table>
<caption>Weekly practice hours</caption>
<thead><tr><th scope="col">Day</th><th scope="col">Hours</th></tr></thead>
<tbody>
<tr><th scope="row">Monday</th><td>2</td></tr>
<tr><th scope="row">Tuesday</th><td>1</td></tr>
</tbody>
</table>
Let’s Read the Code
- Read from the outside inward: the outer element describes the job, while the nested elements supply the information.
Read the named elements and attributes together. They explain how the browser connects this feature to the rest of the page.
What Happens in the Browser?
Try this with Tab and Shift+Tab. If you can, inspect the accessibility tree too; appearance alone does not tell the whole story.
Try a different way of reading. Read only the headings and labels, or navigate through links without looking at the rest of the page. If the page still makes sense, the underlying HTML is probably doing an important part of its job.
Your Turn
Use Tab and Shift+Tab to visit the controls, then read their labels aloud. Is the purpose of each one clear?
Common Beginner Mistakes
- Judging the page only by how it looks, without checking its meaning and keyboard behavior.
- Check the same result using both the browser and a keyboard, not only by looking at the screen.
Key Takeaways
- Caption explains what the table is about.
- Read from the outside inward: the outer element describes the job, while the nested elements supply the information.
- Test the behavior you expect rather than trusting how the snippet looks in your editor.