colspan Attribute


 

Where to use the colspan Attribute

  • As Type Number - default="1":
    colspan is declared on the elements: th, td

Description

The colspan attribute is used on a table cell (td or th) to specify the number of columns to be spanned by the cell.

For example:

<table border="1"><tbody>
<tr><td colspan="3">This cell spans three table columns</td> <td>but</td></tr>
<tr><td>each</td> <td>other cell</td> <td>spans</td> <td>only one</td></tr>
</tbody></table>

This renders as:

This cell spans three table columns but
each other cell spans only one

The default value is "1" and the special value of "0" indicates that the cell should span all remaining columns, from the current column to the last column in the current column group (defined by a colgroup element). If no column groups are explicitly defined, the cell should span to the last column of the table itself.

Note: the special case of colspan="0" is not very well supported across user agents.

Although not stated officially (not that I can find, anyway) I would suggest that any cell which spans multiple columns should not cross a colgroup boundary.

See also the rowspan attribute.


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 16 May 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Attribute Index (XHTML 1.1) > colspan Attribute (XHTML 1.1)