The span attribute on a <col> element specifies the number of columns the element spans, i.e. covers.
This is useful when styling multiple columns.
A span attribute on a <col> element.
Two spanned columns are styled with a background color.
Name | Age | Country |
---|---|---|
Christina Berglund | 35 | Sweden |
Maria Larsson | 27 | Sweden |
<style>
table.tb { width: 350px; border-collapse: collapse; }
.tb th, .tb td { padding:5px; border: 1px solid #777; }
</style>
<table class="tb">
<colgroup>
<col span="2" style="background-color:aliceblue;">
</colgroup>
<tr>
<th>Name</th>
<th>Age</th>
<th>Country</th>
</tr>
<tr>
<td>Christina Berglund</td>
<td>35</td>
<td>Sweden</td>
</tr>
<tr>
<td>Maria Larsson</td>
<td>27</td>
<td>Sweden</td>
</tr>
</table>
<col span="number">
Value | Description |
---|---|
number | Number of columns the <col> extends. |
Here is when span support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |