You can merge cells in tables so that they span more than one column or row. You
use the colspan and rowspan
attributes in the <td> and <th>
tags: the colspan attribute
creates a cell that spans more than one column and the rowspan
attribute creates a cell that spans more than one rows.
You might, for example, span several columns with a heading.
|
|
<table width="250" border="1">
<tr>
<th colspan="2">Fruit and Vegetables</th>
</tr>
<tr valign="top" align="left">
<td>Apples</td>
<td>Celery </td>
</tr>
<tr valign="top" align="left">
<td>Oranges</td>
<td>Carrots </td>
</tr>
<tr valign="top" align="left">
<td>Bananas</td>
<td>Cabbage</td>
</table>
|
|
You might span several rows with a paragraph of text:
|
|
<table width="250" border="1">
<tr>
<th colspan="3">Fruit and Vegetables</th>
</tr>
<tr valign="top" align="left">
<td rowspan="3">Choose your favourite fruit or vegetable</td>
<td>Apples</td>
<td>Celery </td>
</tr>
<tr valign="top" align="left">
<td>Oranges</td>
<td>Carrots </td>
</tr>
<tr valign="top" align="left">
<td>Bananas</td>
<td>Cabbage</td>
</table>
|
|
|
|
More information
Using tables
Creating a basic table
Sizing a table
Adding borders to a table
Adding spacing to a table
Adding a background picture to a table
Using colour in a table
Formatting text in a table
Aligning a table on the page
Aligning cells in tables
Adding captions to a table
Adding headers and footers
Adding blank lines to a table
Spanning rows and columns
Grouping columns |