The element groups the header rows of a table, typically containing The The groups header rows, and The selector 'table thead th' targets all The 'scope' attribute on Pass the test and this pattern moves unknown cells that describe each column. tag defines a header cell in a table, which is usually bold and centered by default. <table>
<thead>
<tr><th>Name</th><th>Age</th></tr>
</thead>
<tbody>
<tr><td>Alice</td><td>30</td></tr>
<tr><td>Bob</td><td>25</td></tr>
</tbody>
</table>
cells are bold and centered by default, so the top row shows 'Name' and 'Age' as headers. elements inside . inside the specifically. elements inside the of a table. header cell to its related cells for screen readers. elements specifies whether the header applies to a row, column, or group, helping screen readers understand the table structure. Practice
<th> tag in an HTML table?Solution
Step 1: Understand the role of
The <th><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 AQuick Check:
Table headers = <th> tag [OK]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 DQuick Check:
Header cell = <th> [OK]<th> elements in most browsers?<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Alice</td>
<td>30</td>
</tr>
</tbody>
</table>Solution
Step 1: Understand default browser styles for <th>
Browsers typically render <th> cells with bold text and center alignment to distinguish headers.Step 2: Compare with data cells
Data cells (<td>) are usually normal weight and left-aligned by default.Final Answer:
The header cells will be bold and centered by default -> Option CQuick Check:
<th> = bold + center [OK]<table>
<thead>
<tr>
<th>Product</td>
<th>Price</th>
</tr>
</thead>
</table>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 BQuick Check:
Matching tags for <th> = </th> [OK]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 correctly uses Row1 Data1 Data2 <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 AQuick Check:
Row and column headers = <th> tags [OK]Ready to prove it?
Table headers in HTML - Practice Problems & Coding Challenges
Challenge - 5 Problems
Table Header Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateWhat is the purpose of the element in an HTML table?
Choose the best description of the element's role in a table.
Attempts:
2 left
💡 Hint
Think about which part of the table usually contains column titles.
✗ Incorrect
📝 Syntax
intermediateWhich HTML snippet correctly defines a table header cell?
Select the option that uses the correct tag for a table header cell.
Attempts:
2 left
💡 Hint
Table header cells use a special tag different from normal cells.
✗ Incorrect
❓ rendering
advancedWhat will the browser display for this table snippet?
Given the HTML below, what is the visual output in the browser?
HTML
Attempts:
2 left
💡 Hint
Headers inside usually appear bold and centered.
✗ Incorrect
❓ selector
advancedWhich CSS selector targets only table header cells inside the table header section?
Choose the CSS selector that styles only
Attempts:
2 left
💡 Hint
Think about selecting
✗ Incorrect
❓ accessibility
expertWhich attribute improves accessibility by associating a table header with its data cells?
Select the attribute that links a
Attempts:
2 left
💡 Hint
This attribute defines if the header is for a row, column, or group.
✗ Incorrect
1. What is the main purpose of the
easy
Hint: Headers label columns or rows using <th> tags [OK]
Common Mistakes:
2. Which of the following is the correct syntax to create a table header cell for a column named "Name"?
easy
Hint: Use <th> for header cells, not <td> or <header> [OK]
Common Mistakes:
3. Given the following HTML snippet, what will be the visual effect of the
medium
Hint: Headers appear bold and centered by default [OK]
Common Mistakes:
4. Identify the error in this table header code:
medium
Hint: Match opening and closing tags exactly for <th> [OK]
Common Mistakes:
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
Hint: Use <th> for headers in both top row and first column [OK]
Common Mistakes:
Recommended
10 questions ~5 mineasy hard
