Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <col> span Attribute

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.

Example

#

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>

Syntax

<col span="number">

Values

#

Value Description
number Number of columns the <col> extends.

Browser support

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

You may also like

 Back to <col>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides