HTML Tables
In the previous lesson, we learned about HTML forms. Now, let's learn about HTML tables and how to use them to display tabular data.
HTML tables are used to display data in a tabular format. Here is a basic example of a table:
<table>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
<td>New York</td>
</tr>
<tr>
<td>Jane</td>
<td>30</td>
<td>Los Angeles</td>
</tr>
</table>
Here are some common table elements that you will use frequently:
Let's see how to use some of these table elements in an HTML document:
<table>
<caption>Student Grades</caption>
<thead>
<tr>
<th>Name</th>
<th>Math</th>
<th>Science</th>
<th>English</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>A</td>
<td>B</td>
<td>A</td>
</tr>
<tr>
<td>Bob</td>
<td>B</td>
<td>A</td>
<td>C</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">End of Table</td>
</tr>
</tfoot>
</table>