HTML <th> colspan attribute

Definition and usage

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

Example

HTML table containing a header cell spanning two columns:

<table>
  <tr>
    <th colspan="2">Monthly savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>¥3000</td>
  </tr>
  <tr>
    <td>February</td>
    <td>¥4000</td>
  </tr>
</table>

Try it yourself

Syntax

<th colspan="number">

Attribute values

Value Description
number

Set the number of columns the header cell should span.

Note:colspan="0" tells the browser to span the cell to the last column of the column group (colgroup).

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Note:Only Firefox supports colspan="0"It has a special meaning (see the 'Attribute Values' table above).