Bird
Raised Fist0
HTMLmarkup~20 mins

Table accessibility basics in HTML - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Table Accessibility Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use in tables?
What is the main purpose of the element in an HTML table for accessibility?
ATo provide a visible title or description for the table that screen readers announce.
BTo add a footer note at the bottom of the table.
CTo create a clickable link inside the table header.
DTo style the table with colors and borders.
Attempts:
2 left
💡 Hint
Think about how screen readers understand what a table is about.
📝 Syntax
intermediate
2:00remaining
Correct use of for headers
Which option correctly marks the first row as header cells in a table for accessibility?
HTML
<table>
  <tr>
    <td>Product</td>
    <td>Price</td>
  </tr>
  <tr>
    <td>Apple</td>
    <td>$1</td>
  </tr>
</table>
A
&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;td&gt;Product&lt;/td&gt;
      &lt;td&gt;Price&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Apple&lt;/td&gt;
      &lt;td&gt;$1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
B
&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;Product&lt;/td&gt;
    &lt;td&gt;Price&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;Apple&lt;/th&gt;
    &lt;th&gt;$1&lt;/th&gt;
  &lt;/tr&gt;
&lt;/table&gt;
C
&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;Product&lt;/th&gt;
    &lt;th&gt;Price&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Apple&lt;/td&gt;
    &lt;td&gt;$1&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
D
&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Product&lt;/th&gt;
      &lt;td&gt;Price&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Apple&lt;/td&gt;
      &lt;td&gt;$1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
Attempts:
2 left
💡 Hint
Headers should use the tag, not .
❓ selector
advanced
2:00remaining
Selecting header cells for row headers
Which CSS selector correctly styles all row header cells in a table for accessibility?
Atable td[scope="row"] { font-weight: bold; }
Btable td[scope="col"] { font-weight: bold; }
Ctable th[scope="col"] { font-weight: bold; }
Dtable th[scope="row"] { font-weight: bold; }
Attempts:
2 left
💡 Hint
Row headers use with a specific scope attribute.
❓ layout
advanced
2:00remaining
Responsive table design for accessibility
Which CSS approach best helps make a wide table accessible on small screens?
AUse overflow-x: auto on a container around the table to allow horizontal scrolling.
BHide some columns with display: none to fit the screen.
CSet table width to 100% and use fixed column widths with px units.
DUse float: left on table cells to stack them vertically.
Attempts:
2 left
💡 Hint
Think about preserving all data while allowing easy navigation on small screens.
❓ accessibility
expert
3:00remaining
Using ARIA roles for complex tables
In a complex data table with merged cells, which ARIA role helps assistive technologies understand the table structure best?
Arole="presentation" on the table element
Brole="grid" on the table element
Crole="button" on the table element
Drole="list" on the table element
Attempts:
2 left
💡 Hint
This role treats the table like a grid of cells with keyboard navigation support.

Practice

(1/5)
1. What is the main purpose of the <caption> element in an HTML table?
easy
A. To add a footer row at the bottom of the table.
B. To provide a title or description for the table, improving accessibility.
C. To create a header cell for each column.
D. To style the table with colors and fonts.

Solution

  1. Step 1: Understand the role of <caption>

    The <caption> element is used to give a title or description to a table, which helps screen readers and users understand the table's content.
  2. Step 2: Compare with other options

    Options B, C, and D describe other table parts or styling, but only <caption> provides a descriptive title.
  3. Final Answer:

    To provide a title or description for the table, improving accessibility. -> Option B
  4. Quick Check:

    <caption> = Table title [OK]
Hint: Caption tags give tables a clear title for screen readers [OK]
Common Mistakes:
  • Confusing <caption> with <tfoot> or <thead>
  • Thinking <caption> styles the table
  • Ignoring accessibility benefits of <caption>
2. Which of the following is the correct way to mark a header cell for a column in an HTML table?
easy
A. <td scope="col">Header</td>
B. <td>Header</td>
C. <th scope="row">Header</th>
D. <th scope="col">Header</th>

Solution

  1. Step 1: Identify the correct element for header cells

    The <th> element is used for header cells, not <td>.
  2. Step 2: Understand the scope attribute

    For column headers, scope="col" is correct. <th scope="col">Header</th> uses <th scope="col">, which is the proper syntax.
  3. Final Answer:

    <th scope="col">Header</th> -> Option D
  4. Quick Check:

    <th scope="col"> = Column header [OK]
Hint: Use <th> with scope="col" for column headers [OK]
Common Mistakes:
  • Using <td> instead of <th> for headers
  • Mixing scope="row" with column headers
  • Omitting the scope attribute
3. Given the following table snippet, what will screen readers associate the header "Name" with?
<table>
  <caption>User List</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Age</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Alice</td>
      <td>30</td>
    </tr>
  </tbody>
</table>
medium
A. The header "Name" is linked to the first column cells like "Alice".
B. The header "Name" is linked to the first row cells like "Alice" and "30".
C. The header "Name" is ignored by screen readers because it lacks an id.
D. The header "Name" is linked to the entire table caption.

Solution

  1. Step 1: Understand scope="col" usage

    The scope="col" attribute on the <th> means the header applies to the entire column below it.
  2. Step 2: Identify which cells belong to the "Name" column

    The first column cells, such as "Alice", are associated with the "Name" header for screen readers.
  3. Final Answer:

    The header "Name" is linked to the first column cells like "Alice". -> Option A
  4. Quick Check:

    scope="col" links header to column cells [OK]
Hint: scope="col" links header to column cells below [OK]
Common Mistakes:
  • Confusing row and column scope
  • Thinking headers need id attributes to link
  • Assuming caption links headers
4. What is wrong with this table snippet regarding accessibility?
<table>
  <tr>
    <td>Product</td>
    <td>Price</td>
  </tr>
  <tr>
    <td>Book</td>
    <td>$10</td>
  </tr>
</table>
medium
A. The table is missing <caption> for description.
B. The header cells use <td> instead of <th>.
C. All of the above.
D. The scope attribute is missing on header cells.

Solution

  1. Step 1: Check for caption element

    The table lacks a <caption>, which helps describe the table for screen readers.
  2. Step 2: Check header cell tags and attributes

    The first row uses <td> instead of <th> for headers, and no scope attributes are present.
  3. Final Answer:

    All of the above. -> Option C
  4. Quick Check:

    Missing caption, wrong header tags, and no scope = C [OK]
Hint: Headers need <th> with scope and caption for full accessibility [OK]
Common Mistakes:
  • Using <td> for headers
  • Skipping caption element
  • Not adding scope attribute to headers
5. You want to create an accessible table showing students and their scores. Which combination of elements and attributes is best practice?
hard
A. Use <caption> for the title, <th scope="col"> for column headers, and <th scope="row"> for row headers.
B. Use <caption> for the title, <td> for all cells, and no scope attributes.
C. Use <thead> with <td> for headers and <tbody> for data rows.
D. Use <caption> for the title and aria-label on each <td> cell.

Solution

  1. Step 1: Use <caption> for table description

    This helps all users understand the table's purpose.
  2. Step 2: Use <th> with proper scope for headers

    Column headers get scope="col", row headers get scope="row". This clarifies relationships for screen readers.
  3. Final Answer:

    Use <caption> for the title, <th scope="col"> for column headers, and <th scope="row"> for row headers. -> Option A
  4. Quick Check:

    Caption + th with scope col/row = best accessibility [OK]
Hint: Caption plus <th> with scope="col" and scope="row" is best [OK]
Common Mistakes:
  • Using <td> for headers
  • Skipping scope attributes
  • Relying only on aria-labels on data cells
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard