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>Rs.100</td>
</tr>
<tr>
<td>February</td>
<td>Rs.100</td>
</tr>
<tr>
<td colspan="2">Sum: Rs.180</td>
</tr>
</table>

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>Rs.100</td>
</tr>
<tr>
<td>February</td>
<td>Rs.80</td>
</tr>
</table>

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

Comments