rowspan (HTML attribute)

Spec
Depr. Version
No HTML 3.2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Partial Full Partial Full Partial

Syntax

rowspan="number"

Description

Where information may be relevant to multiple rows in the table, the cell containing that information can be set to span these rows using the rowspan attribute. In the colspan example for this element, which is shown in Figure 1, we saw a calendar that showed a person’s work availability, with the days running along the x axis (horizontally) and time slots running down the y axis (vertically). If this table was turned through 90 degrees, it would convey exactly the same information, only the availability would span rows rather than columns. Compare the HTML example above with Figure 1.

Figure 1. Rowspans applied to several cells in this table showing someone’s availability for work Rowspans applied to several cells in this table showing someone’s availability for work.

When you’re introducing a rowspan attribute, take care to ensure that every row adds up to same number of cells. Some tables can become quite complicated with a mixture of colspan and rowspan attributes, and this is not something that you’re advised to hand-code—that’s just asking for trouble! It’s much better to use a WYSIWYG editor, such as Dreamweaver, MS Expression, or something similar, which will allow you to merge and unmerge cells very easily, and takes care of these attributes for you.

Example

Here’s an extract from a calendar, with a person’s availability showing that half the day is free, and half is busy, as shown in Figure 1:

  <tr>
    <th>Evening</th>
    <td rowspan="2">Free</td>
    <td rowspan="2">Busy</td>
  </tr>

Value

This attribute takes a number, which should equal the number of rows that the spanned td cell needs to cover. A special value of "0" can also be used to inform the browser to span the cell to the end of all the rows inside the current rowgroup (thead, tfoot, or tbody).

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Partial Partial Partial Partial Full Full Full Full Full Partial Partial Partial Partial Full Full Full Partial

Browser support for rowspan is generally good, with one exception: the rendering of rowspan="0". Firefox and Opera are the only browsers tested that correctly span the cell to which this attribute is applied across all subsequent rows; the other browsers tested render the cell in the first row only.

User-contributed notes

There are no comments yet.

Related Products