HTML <th> colspan Attribute

❮ HTML <th> tag

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 »

Definition and Usage

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


Browser Support

Attribute
colspan Yes Yes Yes Yes Yes

Note: Only Firefox supports colspan="0", which has a special meaning (look below in the "Attribute Values" table).


Syntax

<th colspan="number">

Attribute Values

Value Description
number Sets the number of columns a header cell should span. Note: colspan="0" tells the browser to span the cell to the last column of the column group (colgroup)

❮ HTML <th> tag
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.