Latest web development tutorials

HTML th colspan attribute

HTML th tag Reference Manual HTML <th> tag

Examples

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

<table border="1">
<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"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support colspan attribute.

Note: Only Firefox supports colspan = "0", this value has a special meaning (see below "property values" table).


Definition and Usage

The number of columns colspan attribute definition header cell should span of.


Differences between HTML 4.01 and HTML5

no.


grammar

<th colspan="number">

Property Value

描述
number 规定表头单元格应该横跨的列数。注意: colspan="0" 告知浏览器使单元格横跨到列组 (colgroup) 的最后一列。


HTML th tag Reference Manual HTML <th> tag