HTML colspan Attribute

The colspan attribute on a table cell element specifies the number of columns this cell should occupy, i.e. span.

Elements that accept this attribute are <td>, and <th>.



A colspan attribute on a <td> element.
The last row stretches over two columns.

Investor Amount
Joel Nais $250
Tom Simpson $300
Greta Waltz $100
Total amount invested: $650
  table.tb {width:300px;border-collapse:collapse;}
  .tb th {background-color:lightblue;}
  .tb th, .tb td {border:solid 1px #777;padding:5px;}

<table class="tb">
      <td>Joel Nais</td>
      <td>Tom Simpson</td>
      <td>Greta Waltz</td>
      <td colspan="2">Total amount invested: <b>$650</b></td>

For additional details see our HTML td colspan Reference.

Using colspan

A value of 0 will span until the last column in the current <colgroup> (column group).

The default value is 1, meaning no column span.


<tagname colspan="number">



Value Description
number Number of columns the table cell should span.

Elements that accept colspan

These table elements accept the colspan attribute.

Elements Description
<td> Creates a standard table cell -- see example above
<th> Creates a table header cell.

<th> with colspan

A <th> tag with a colspan attribute.
The first header cell spans two columns.

Name Country
Denice Templeman Italy
Paulo Cornell USA
Maria Larsson Sweden
  table.tbl {width:300px;border-collapse:collapse;}
  .tbl th, .tbl td {border:solid 1px #777;padding:5px;}
  .tbl th {background-color: lightblue;}

<table class="tbl">
    <th colspan="2">Name</th> 

For additional details see our HTML th colspan Reference.

Browser support

Here is when colspan 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