English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <th> colspan attribute

Usage of the <th> colspan attribute, the colspan attribute defines the number of columns the header cell should span, an online instance demonstrates how to use the <th> colspan attribute, browser compatibility, syntax definition, and detailed information about its attribute values.

 HTML <th> tag

Online Example

The following HTML table contains a header cell spanning two columns:

<table style="width:100%" border="1">
  <tr>
    <th colspan="2">Year Income</th>
  </tr>
  <tr>
    <td>2018</td>
    <td>$15320.00</td>
  </tr>
  <tr>
    <td>2019</td>
    <td>$18320.00</td>
  </tr>
</table>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the colspan attribute.

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

Definition and Usage

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

HTML 4.01 With HTML5Differences

None.

Syntax

<th colspan="number">

Attribute Value

ValueDescription
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)

 HTML <th> tag