HTML and CSS Reference
How to tell cells to span more than one row
What does it mean for a cell to span more than one row? Let's look at the entries
for Truth or Consequences, NM, in Tony's table again. The data cells for city,
altitude, and population span two rows , not one, while the date, temp, and diner
rating span one row, which is the normal, default behavior for data cells.
Walla Walla, WA
Magic City, ID
Last Chance, CO
These c ells span t wo rows.
So, how do you do that in HTML? It's easier than you might think: you use the
rowspan attribute to specify how many rows a table data cell should take up, and
then remove the corresponding table data elements from the other rows that the cell
spans over. Have a look—it's easier to see than describe:
He re are the two ta ble
ro ws that have the New
Me xico data.
<td rowspan="2">Truth or Consequences, NM</td>
<td class="center">August 9th</td>
<td rowspan="2" class="right">4,242 ft</td>
<td rowspan="2" class="right">7,289</td>
<td class="center">August 27th</td>
The city is not
of the rowspan.
Then in the second row, we
specify just the columns we need
(date, temp, and a new rating).