Problem Statement
What is the purpose of the <thead> tag?
Explanation
The thead tag is used to group the header content in a table. It is a semantic container that wraps the rows containing column headers. The thead tag should contain one or more tr tags with th cells. Using thead has several benefits. First, it provides semantic meaning, helping browsers and screen readers understand the table structure. Second, when printing long tables, browsers can repeat the thead on each printed page. Third, it allows for easier styling of the header section separately from the body. The thead tag is optional but recommended for well-structured tables. It should be placed after the caption if present, and before tbody and tfoot. Modern web development uses thead, tbody, and tfoot to create clearly defined table sections.
Code Solution
SolutionRead Only
<!-- Table with thead -->
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>john@example.com</td>
<td>555-1234</td>
</tr>
<tr>
<td>Jane Smith</td>
<td>jane@example.com</td>
<td>555-5678</td>
</tr>
</tbody>
</table>