Problem Statement
Which tag is used to create a table in HTML?
Explanation
The table tag is used to create a table in HTML. Tables are used to organize data in rows and columns, making it easy to display structured information like schedules, price lists, or comparison charts. A basic table consists of several elements working together. The table tag is the container for the entire table. The tr tag defines table rows. The td tag defines table data cells. The th tag defines table header cells. Every table must have at least one row with at least one cell. Tables are block-level elements that take up the full width available by default. Modern web development uses tables primarily for tabular data, not for page layout. CSS grid and flexbox are preferred for layouts. Understanding proper table structure is essential for displaying data effectively.
Code Solution
SolutionRead Only
<!-- Basic table structure -->
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
</tr>
<tr>
<td>Sarah</td>
<td>30</td>
</tr>
</table>