What HTML tag is used to define a table header cell?
The <th> tag is used to define a table header cell in HTML. It makes the cell content bold and centered by default.
Click to reveal answer
beginner
How do table headers improve accessibility?
Table headers help screen readers understand the structure of the table by labeling rows or columns. This makes it easier for users with disabilities to navigate and understand the data.
Click to reveal answer
intermediate
What attribute connects a table data cell to a header cell for accessibility?
The headers attribute on a <td> cell links it to one or more <th> cells by their id. This helps assistive technologies relate data cells to their headers.
Click to reveal answer
beginner
What is the difference between <th> and <td> tags?
<th> defines a header cell, usually bold and centered, while <td> defines a regular data cell in a table.
Click to reveal answer
intermediate
How can you specify that a <th> is a header for a row or a column?
Use the scope attribute on <th>. Set it to col for column headers or row for row headers. This helps screen readers understand the header's role.
Click to reveal answer
Which tag is used to create a header cell in an HTML table?
A<th>
B<td>
C<header>
D<tr>
✗ Incorrect
The <th> tag defines a header cell in an HTML table.
What attribute should you add to a <th> to specify it is a column header?
Atype="column"
Bheader="column"
Cscope="col"
Drole="columnheader"
✗ Incorrect
The scope="col" attribute on <th> specifies it is a column header.
Why are table headers important for accessibility?
AThey add color to the table
BThey help screen readers understand table structure
CThey make tables load faster
DThey allow sorting of table data
✗ Incorrect
Table headers help screen readers understand the table's rows and columns.
Which attribute links a data cell to its header cell?
Aheaders
Bid
Cscope
Dfor
✗ Incorrect
The headers attribute on <td> links it to one or more <th> cells by their ids.
What is the default style of a <th> cell in most browsers?
AItalic and left aligned
BNormal weight and justified
CUnderlined and right aligned
DBold and centered
✗ Incorrect
By default, <th> cells are bold and centered.
Explain how to create accessible table headers in HTML and why they matter.
Think about how screen readers read tables and how headers help.
You got /4 concepts.
Describe the difference between
and
tags and their roles in a table.
Consider how headers label rows or columns.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the <th> tag in an HTML table?
easy
A. To define a header cell that labels a column or row
B. To create a normal data cell in a table
C. To add a caption above the table
D. To merge multiple cells into one
Solution
Step 1: Understand the role of <th>
The <th> tag is used to create header cells in a table, which label columns or rows.
Step 2: Differentiate from other tags
The <td> tag creates normal data cells, not headers. Captions use <caption>, and merging cells uses colspan or rowspan.
Final Answer:
To define a header cell that labels a column or row -> Option A
Quick Check:
Table headers = <th> tag [OK]
Hint: Headers label columns or rows using <th> tags [OK]
Common Mistakes:
Confusing <th> with <td>
Thinking <th> merges cells
Using <caption> as header cells
2. Which of the following is the correct syntax to create a table header cell for a column named "Name"?
easy
A. Name
B.
Name
C. Name
D.
Name
Solution
Step 1: Identify the tag for header cells
The correct tag for a table header cell is <th>.
Step 2: Check the options
<td> is for data cells, <header> is a page section tag, and <thead> groups header rows but does not create individual cells.
Final Answer:
<th>Name</th> -> Option D
Quick Check:
Header cell = <th> [OK]
Hint: Use <th> for header cells, not <td> or <header> [OK]
Common Mistakes:
Using <td> instead of <th>
Confusing <thead> with <th>
Using non-table tags like <header>
3. Given the following HTML snippet, what will be the visual effect of the <th> elements in most browsers?
A. The second header cell uses <th> instead of <td>
B. The first header cell closes with </td> instead of </th>
C. The <tr> tag is not closed
D. The <thead> tag is missing
Solution
Step 1: Check tag consistency in header cells
The first header cell starts with <th> but incorrectly closes with </td>, which is invalid.
Step 2: Verify other tags
The <thead> and <tr> tags are correctly used and closed. The second header cell uses <th> correctly.
Final Answer:
The first header cell closes with </td> instead of </th> -> Option B
Quick Check:
Matching tags for <th> = </th> [OK]
Hint: Match opening and closing tags exactly for <th> [OK]
Common Mistakes:
Mixing <th> and <td> tags
Forgetting to close <tr> or <thead>
Using <td> inside <thead>
5. You want to create a table where the first column uses header cells to label each row, and the top row uses header cells to label each column. Which is the correct way to do this?
hard
A.
Col1
Col2
Row1
Data1
Data2
B.
Col1
Col2
Row1
Data1
Data2
C.
Col1
Col2
Row1
Data1
Data2
D.
Col1
Col2
Row1
Data1
Data2
Solution
Step 1: Use <th> for both column and row headers
The top row headers and the first column headers should use <th> tags to indicate headers.
Step 2: Check the provided options
Col1
Col2
Row1
Data1
Data2
correctly uses <th> in the top row and first column. The empty <th> in the top-left corner aligns headers properly.
Final Answer:
Option A uses <th> for both row and column headers correctly -> Option A
Quick Check:
Row and column headers = <th> tags [OK]
Hint: Use <th> for headers in both top row and first column [OK]
Common Mistakes:
Using <td> for headers in the first column
Leaving top-left cell empty without <th>
Mixing <td> and <th> incorrectly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.