Tables
- Used for tabular data
- Allows to arrange data into rows and columns.
<table>
tag defines an HTML table.
- Each table row is defined with a
<tr>
tag.
- Each table header is defined with a
<th>
tag.
- Each table data/cell is defined with a
<td>
tag.
- Table data cell can contain all sorts of HTML elements; text, images, lists, other tables, etc.
- Use
colspan
for cells that spans many columns
- Use
rowspan
for cells that spans many rows
- Use
<caption>
tag to add a caption to a table and must be inserted immediately after the <table>
tag
<thead>
tag is used to group header content in an HTML table.
<tbody>
tag is used to group the body content in an HTML table.
<tfoot>
tag is used to group footer content in an HTML table.
<table>
<tr>
<th>Items</th>
<th>Amount</th>
</tr>
<tr>
<td>Bread</td>
<td>40</td>
</tr>
<tr>
<td>Milk</td>
<td>30</td>
</tr>
<tr>
<th>Total</th>
<th>70</th>
</tr>
</table>