HTML span Attribute

The span attribute on a <col> or <colgroup> element specifies the number of columns the element should span, i.e. cover.

This is useful when the same style needs to be applied to multiple columns.



A span attribute on a <col> element.
Two spanned columns are styled with the same background color.

Name Age Country
Christina Berglund 35 Sweden
Maria Larsson 27 Sweden
  table.tb { width: 350px; border-collapse: collapse; }
  .tb th, .tb td { padding:5px; border: 1px solid #777; }

<table class="tb">
    <col span="2" style="background-color:aliceblue;">
      <td>Christina Berglund</td>
      <td>Maria Larsson</td>

For additional details see our HTML col span Reference.


<tagname span="number">



Value Description
number Number of columns the element should span.

Elements that accept span

The following elements accept the span attribute.

Elements Description
<col> Groups and styles table columns -- see example above
<colgroup> Serves as a container for col elements.

<colgroup> with span

A <colgroup> tag with a span attribute.
The colgroup spans two columns that are styled with a background color.

Id First Name Last Name Country
ART-303 Vincent Van Gogh Netherlands
ART-877 Paul C├ęzanne France
  table.tbl { width:450px; border-collapse: collapse; }
  .tbl th, .tbl td { padding:3px; border: 1px solid #777; }

<table class="tbl">
  <colgroup span="2" style="background-color:aliceblue;">
      <th>First Name</th>
      <th>Last Name</th>
      <td>Van Gogh</td>

For additional details see our HTML colgroup span Reference.

Browser support

Here is when span support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like

Last updated on Sep 30, 2023