HTML Tables
Tables are used to display data in rows and columns.
Basic Table Structure
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>25</td>
<td>New York</td>
</tr>
<tr>
<td>Sarah</td>
<td>30</td>
<td>London</td>
</tr>
</tbody>
</table>
Table Elements
<table>- Defines a table<tr>- Defines a row<th>- Defines a header cell<td>- Defines a data cell<thead>- Groups header content<tbody>- Groups body content<tfoot>- Groups footer content
Spanning Cells
Column Span
<td colspan="2">Spans 2 columns</td>
Row Span
<td rowspan="3">Spans 3 rows</td>
Best Practices
- Use semantic markup
- Include proper headers
- Keep tables simple
- Consider mobile responsiveness
- Use CSS for styling