HTML Tables
HTML tables are used to display data in rows and columns. They are created using the <table>
element.
Basic Table Structure
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>Alice</td>
<td>30</td>
<td>New York</td>
</tr>
<tr>
<td>Bob</td>
<td>25</td>
<td>Los Angeles</td>
</tr>
</table>
Table with Caption
Use the <caption>
tag to add a caption to your table.
<table border="1">
<caption>Employee Details</caption>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>Alice</td>
<td>30</td>
<td>New York</td>
</tr>
<tr>
<td>Bob</td>
<td>25</td>
<td>Los Angeles</td>
</tr>
</table>
Table with Colspan and Rowspan
Use colspan
and rowspan
to merge cells.
<table border="1">
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Alice</td>
<td rowspan="2">30</td>
<td>New York</td>
</tr>
<tr>
<td>Bob</td>
<td>Los Angeles</td>
</tr>
</table>
Next: HTML Multimedia