Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a table header cell.
HTML
<table>
<tr>
<[1]>Name</[1]>
</tr>
</table>Attempts:
3 left
💡 Hint
Common Mistakes
Using instead of for header cells.
Using or tags incorrectly inside a row. Drag options to blanks, or click blank then click option'
✗ Incorrect
The <th> tag defines a header cell in a table row.
2fill in blank
mediumComplete the code to add a table header row inside the table head section.
HTML
<table> <[1]> <tr> <th>Age</th> </tr> </[1]> </table>
Attempts:
3 left
💡 Hint
Common Mistakes
Using or instead of for header rows.
Using as a container tag. Drag options to blanks, or click blank then click option'
✗ Incorrect
The <thead> tag groups the header content in a table.
3fill in blank
hardFix the error in the table header cell tag.
HTML
<table>
<tr>
<[1]>Email</[1]>
</tr>
</table>Attempts:
3 left
💡 Hint
Common Mistakes
Mixing and tags in the same cell.
Using or tags incorrectly. Drag options to blanks, or click blank then click option'
✗ Incorrect
The opening tag must match the closing tag. Use <th> for header cells, not <td>.
4fill in blank
hardFill both blanks to create a table with a header and body.
HTML
<table> <[1]> <tr><th>City</th></tr> </[1]> <[2]> <tr><td>Paris</td></tr> </[2]> </table>
Attempts:
3 left
💡 Hint
Common Mistakes
Using instead of for body rows.
Using as a container for multiple rows. Drag options to blanks, or click blank then click option'
✗ Incorrect
<thead> wraps header rows, and <tbody> wraps body rows in a table.
5fill in blank
hardFill all three blanks to create a table with a header row and two body rows.
HTML
<table> <[1]> <tr><th>Name</th><th>Age</th></tr> </[1]> <[2]> <tr><td>Alice</td><td>30</td></tr> <tr><td>Bob</td><td>25</td></tr> </[2]> <[3]></[3]> </table>
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the footer section or using wrong tags.
Using as a container for multiple rows.(1/5)
✗ Incorrect
<thead> for header, <tbody> for body, and <tfoot> for footer sections of a table.
Practice
1. What is the main purpose of the
<th> tag in an HTML table?easy
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 usescolspanorrowspan.Final Answer:
To define a header cell that labels a column or row -> Option AQuick 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
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]
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?<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>medium
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]
Hint: Headers appear bold and centered by default [OK]
Common Mistakes:
- Thinking headers are italic
- Assuming headers look like data cells
- Believing headers are hidden
4. Identify the error in this table header code:
<table>
<thead>
<tr>
<th>Product</td>
<th>Price</th>
</tr>
</thead>
</table>medium
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]
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
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 usesRow1 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]
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 unknown
10 questions ~5 mineasy hard
