Basic Table
A simple table uses <table>, rows use <tr>, and cells use <td>:
<table>
<tr>
<td>Apple</td>
<td>Red</td>
</tr>
<tr>
<td>Banana</td>
<td>Yellow</td>
</tr>
</table>
This creates a simple two‑row table.
Table Headings
Use <th> for header cells. They appear bold by default:
<table>
<tr>
<th>Fruit</th>
<th>Color</th>
</tr>
<tr>
<td>Apple</td>
<td>Red</td>
</tr>
</table>
Adding Borders
You can add borders using CSS. For example:
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
This makes your table easier to read.
Spanning Columns
Use colspan to make a cell stretch across multiple columns:
<td colspan="2">Fruit Colors</td>
Lesson Checkpoint
Before moving on, make sure you have:
- Created a table in your
index.html. - Used
<table>,<tr>,<td>, and<th>. - Experimented with borders and
colspan. - Committed your changes to GitHub.
- Viewed your updated site on GitHub Pages.
Use the navigation bar to explore your site or review previous lessons.