span (HTML attribute)

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

Syntax

span="number"

Description

If you wanted to set attributes for individual columns, you could use the col element and apply the relevant attributes to each as you saw fit. However, if a group of a columns shared the same attribute, this approach would necessitate the following repetition of seven columns:

<colgroup align="left">
  <col/>
  <col/>
  <col/>
  <col/>
  <col/>
  <col/>
  <col/>
</colgroup>

Instead, you could simply omit the nested col elements, and state how many columns were required with the span attribute, like so:

<colgroup align="left" span="7">
</colgroup>

If the colgroup contains a span attribute as well as nested col elements, the value in the span is ignored, and the number of col elements is counted instead.

Example

Here, two groups of columns are defined using the span attribute:

<table border="1">
  <colgroup width="60%" span="2"/></colgroup>
  <colgroup width="40%" span="2"/></colgroup>
  <tr>
    <th colspan="4" scope="col">Work Contact Points</th>
  </tr>
  <tr>
    <th>Name</th>
    <th>Email</th>
    <th>Phone</th>
    <th>Floor/Block</th>
  </tr>
  ⋮
</table>

Value

This attribute takes as its value a number that reflects the number of consecutive cells the colgroup represents.

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
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

Support for this attribute has been marked as full, but be aware that this support still depends on whether the other attributes are supported. Safari, for instance, ignores the align attribute, so asking it to span that attribute across two columns has no effect. In short, the successful rendering of span depends on the support for the attributes with which it’s associated.

User-contributed notes

There are no comments yet.

Related Products