[Back] [Next] The Information Commons
.................... Introduction to HTML

4.10.4 The COLSPAN and ROWSPAN Attributes to TD and TH

By default, a cell lies in a given row and column (depending on how you created the table). Sometime, however, you want a cell to "drop down" to the next cell below it, or perhaps stretch across into the next row. This is accomplished using the COLSPAN and ROWSPAN attributes, respectively. COLSPAN indicates how many columns (counting to the right) are occupied by the cell, while ROWSPAN indicated how many rows (hanging down) the cell "spans".

Recall that, when you create a TR row, you must make sure that the number or cells in the columns in the row sum to the correct number (determined by the very first row). In doing so, you must take into account the cells that span across multiple columns (COLSPAN) or hang down from a previous row (ROWSPAN). This is illustrated in the following example.

<TR> <TD> 1.1 <TD> 1.2       <TD> 1.3           <TD> 1.4 </TR>
<TR> <TD> 2.1 <TD COLSPAN=2>      2.2           <TD> 2.4 </TR>
<TR> <TD> 3.1 <TD> 3.2       <TD ROWSPAN=3> 3.3 <TD> 3.4 </TR>
<TR> <TD> 4.1 <TD> 4.2                          <TD> 4.4 </TR>
<TR> <TD> 5.1 <TD> 5.2                          <TD> 5.4 </TR>

The above table is displayed as....

1.1 1.2 1.3 1.4
2.1 2.2 2.4
3.1 3.2 3.3 3.4
4.1 4.2 4.4
5.1 5.2 5.4

[Back] [Next] .................... Introduction to HTML

Page Last Updated: 4 December 1995