HTML <colgroup> spanAttribute
Examples
Use the <colgroup> span attribute to set the background color of the first two columns:
<table border="1">
<colgroup span="2" style="background:red"></colgroup>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
<tr>
<td>5869207</td>
<td>My first CSS</td>
<td>$49</td>
</tr>
</table>
<colgroup span="2" style="background:red"></colgroup>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
<tr>
<td>5869207</td>
<td>My first CSS</td>
<td>$49</td>
</tr>
</table>
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the span attribute.
Definition and Usage
The span attribute defines the number of columns a <colgroup> element should span.
Tip:To define different attributes for columns within a <colgroup>, use the<col>tag.
Differences between HTML 4.01 and HTML5
None.
Syntax
<colgroup span="number">
Attribute Values
| Value | Description |
|---|---|
| number | Sets the number of columns a column group should span. |
HTML <colgroup> Tag Other Extensions