DiscoveryVIP / HTML & CSS AcademyHelp

19. Table accessibility

Module 4 · About 20 minutes · Lesson 18; review earlier concepts as needed

Open Interactive Lesson

Discover

What changes when you use table accessibility, and how can you prove it?

Predict

Record the expected structure or visual change before rendering. Name one thing that should remain unchanged.

Understand

A caption names the table. scope clarifies whether a header applies to its row or column in simple tables. Complex multi-level tables may need explicit header associations and often benefit from redesign. Visual bold text alone does not make a data cell a header. Review relationships without relying on color or borders.

Important source lines

index.html:1 <table><caption>Available seats</caption><tr><th scope="col">Day</th><th scope="col">Seats</th></tr><tr><th scope="row">Monday</th><td>12</td></tr></table>
Tabular relationships between data in rows and columns. Attribute guidance: use caption and associated headers as needed.
styles.css:1 table { border-collapse: collapse; } th,td { padding:.6rem; border-bottom:1px solid #aaa; }
Chooses a collapsed table-border model. Accepted grammar: separate | collapse. Context: table.

The first example teaches this lesson’s primary contract. Additional examples are optional related references or applications, each with its own purpose and source; an example without an authored check requires the stated visual/manual review.

Example 1: Table accessibility

Monday is a row header and the table caption supplies context for the seat count.

index.html

<table><caption>Available seats</caption><tr><th scope="col">Day</th><th scope="col">Seats</th></tr><tr><th scope="row">Monday</th><td>12</td></tr></table>

styles.css

table { border-collapse: collapse; } th,td { padding:.6rem; border-bottom:1px solid #aaa; }

script.js

Expected: Monday is a row header and the table caption supplies context for the seat count.

Edit and Render This Example
Example 2: Element: table

Tabular relationships between data in rows and columns.

index.html

<table><caption>Sessions</caption><tr><th scope="col">Topic</th><th scope="col">Seats</th></tr><tr><th scope="row">Grid</th><td>12</td></tr></table>

styles.css

body { font:18px/1.6 system-ui; margin:1.5rem; color:#17324d; } img,video,svg { max-width:100%; height:auto; } th,td { padding:.5rem; border:1px solid #a8b8c8; } :focus-visible { outline:3px solid #a44322; outline-offset:3px; }

script.js

Expected: Tabular relationships between data in rows and columns. Review its real DOM and native behavior; structural/media-only examples are labeled.

Edit and Render This Example
Example 3: Element: caption

A table’s visible name or description.

index.html

<table><caption>Monthly attendance</caption><tr><th scope="col">Month</th><th scope="col">People</th></tr><tr><td>June</td><td>24</td></tr></table>

styles.css

body { font:18px/1.6 system-ui; margin:1.5rem; color:#17324d; } img,video,svg { max-width:100%; height:auto; } th,td { padding:.5rem; border:1px solid #a8b8c8; } :focus-visible { outline:3px solid #a44322; outline-offset:3px; }

script.js

Expected: A table’s visible name or description. Review its real DOM and native behavior; structural/media-only examples are labeled.

Edit and Render This Example
Example 4: Element: tr

A table row containing header/data cells.

index.html

<table><tr><th scope="row">Monday</th><td>12 seats</td></tr></table>

styles.css

body { font:18px/1.6 system-ui; margin:1.5rem; color:#17324d; } img,video,svg { max-width:100%; height:auto; } th,td { padding:.5rem; border:1px solid #a8b8c8; } :focus-visible { outline:3px solid #a44322; outline-offset:3px; }

script.js

Expected: A table row containing header/data cells. Review its real DOM and native behavior; structural/media-only examples are labeled.

Edit and Render This Example
Example 5: Element: th

A header cell associated with data.

index.html

<table><tr><th scope="col">Course</th><th scope="col">Level</th></tr><tr><th scope="row">HTML</th><td>Beginner</td></tr></table>

styles.css

body { font:18px/1.6 system-ui; margin:1.5rem; color:#17324d; } img,video,svg { max-width:100%; height:auto; } th,td { padding:.5rem; border:1px solid #a8b8c8; } :focus-visible { outline:3px solid #a44322; outline-offset:3px; }

script.js

Expected: A header cell associated with data. Review its real DOM and native behavior; structural/media-only examples are labeled.

Edit and Render This Example

Build and test

Monday is a row header and the table caption supplies context for the seat count. Repair the current exercise without removing necessary content. Checks inspect the stated structural/computed/stylesheet contract, not exact source text.

Starter index.html

<table><caption>Available seats</caption><tr><th scope="col">Day</th><th scope="col">Seats</th></tr><tr><th scope="col">Monday</th><td>12</td></tr></table>

Starter styles.css

table { border-collapse: collapse; } th,td { padding:.6rem; border-bottom:1px solid #aaa; }

Objective contract

[
  {
    "type": "attr",
    "selector": "th[scope=\"row\"]",
    "property": "scope",
    "value": "row",
    "label": "th[scope=\"row\"] has scope=row"
  }
]
Hint 1

Locate the first difference between the intended result and the real preview. Inspect matching elements and computed styles.

Hint 2

The relevant source uses scope="row". The exercise instead uses scope="col". Identify its effect before changing it.

Hint 3

Restore the intended scope="row" operation or implement an equivalent structure/style. Run the actual checks and explain why it works.

Complete reference solution

index.html

<table><caption>Available seats</caption><tr><th scope="col">Day</th><th scope="col">Seats</th></tr><tr><th scope="row">Monday</th><td>12</td></tr></table>

styles.css

table { border-collapse: collapse; } th,td { padding:.6rem; border-bottom:1px solid #aaa; }

Explain, reflect and extend

Which part of the actual preview or inspector proves this result? Explain one boundary case and name what automated checks do not verify.

Apply this concept to a different realistic piece of content. Predict its structure or visual behavior, test narrow and wide widths where relevant, then record one invalid case and its repair.

Troubleshooting and professional practice

If nothing changes, confirm that you edited the active file and ran Run Preview, or enabled Auto Preview. Inspect the actual DOM because the browser may repair invalid nesting. For CSS, check selector matches, valid declarations, active queries and computed values. Preserve local asset paths and inspect warnings. Monday is a row header and the table caption supplies context for the seat count.

Knowledge check

Explain why the stated result follows from the source. Predict a second input or width and test it independently. Automated contracts and written explanations are reviewed separately.

Optional AI prompts

  1. Explain this lesson’s source line by line using the actual objective above.
  2. Help implement one small extension and define normal, boundary and failure tests.
  3. Review/debug the source against actual preview observations; verify standards and never claim rendering without evidence.

Continue to Lesson 20: Organizing structured information

Detailed learning and editor help · Standards reference