span Attribute


 

Where to use the span Attribute


Description

The span attribute can be used on colgroup and col elements to specify the number of columns to be spanned.

For a col element, the span attribute specifies the number of columns to be "spanned" by the element (default = 1). Any width attribute will then be applied to each of the columns spanned - i.e. the following code will span two adjacent columns and set each to be 40px in width (total width 80px):
<col span="2" width="40" />

For an empty colgroup element, the span attribute specifies the number of columns in that column group. However, if there are any col elements within a colgroup, its span attribute is ignored completely. Instead, the span values (default = 1) of each of its col children are added together to get the number of columns in the group. As was the case with col, any width attribute on a colgroup element will apply to each column within the group, rather than to the group as a whole.

Notes

  • The total number of columns specified using colgroup and col elements (taking into account all relevant span attributes) should always be equal to the actual number of columns in the table as determined by the maximum number of cells in a row (taking into account any colspan and rowspan attributes).
  • Although the default value for span is "1", any colgroup elements which have no col children and span only one column should be given an explicit span="1" attribute. This is because an apparent bug in early versions of Safari defaulted such column groups to a span of "0".

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) > span Attribute (XHTML 1.1)