span (HTML attribute)
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>
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.
Value
This attribute takes as its value a
number that reflects the number of consecutive cells the
colgroup represents.
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | 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.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

