HTML <td>colspan Attribute (original) (raw)
Last Updated : 22 May, 2026
The colspan attribute in the
- Used to merge two or more columns into a single cell.
- Accepts a numeric value indicating the number of columns to span.
- Helps create flexible and structured table layouts.
- Commonly used in headers or grouped data rows.
- Works only with table cells (
or ).
Syntax
Attribute Value
It contains the numeric value which specifies the number of columns a cell should span.
**Example: Illustrates the use of colspan attribute in Table data Element.
html `
HTML <td>colspan AttributeGeeksforGeeks
HTML colspan
Attribute
<table>
<tr>
<th>Name</th>
<th>Expense</th>
</tr>
<tr>
<td>Alen</td>
<td>₹10</td>
</tr>
<tr>
<td>Nicol</td>
<td>₹8</td>
</tr>
<!-- The last row -->
<tr>
<!-- This td will span
two columns, that is
a single column will
take up the space of 2 -->
<td colspan="2">
Sum: ₹18
</td>
</tr>
</table>
`