HTML colspan Attribute


Definition and Usage

The colspan attribute defines the number of columns a table cell should span.


Applies to

The colspan attribute can be used on the following elements:

Elements Attribute
<td> colspan
<th> colspan

Examples

Td Example

An HTML table with a table cell that spans two columns:

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$100</td>
  </tr>
  <tr>
    <td colspan="2">Sum: $180</td>
  </tr>
</table>
Try it Yourself »

Th Example

An HTML table with a header cell that spans two columns:

<table>
  <tr>
    <th colspan="2">Monthly Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>
Try it Yourself »

Browser Support

The colspan attribute has the following browser support for each element:

Element
td Yes Yes Yes Yes Yes
th Yes Yes Yes Yes Yes

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.