The HTML colspan attribute
Quick answer
The HTML colspan attribute makes a table cell span multiple columns. It is used on the <td> and <th> elements.
Overview
The colspan attribute spans a table cell across columns. It is used on table cells (<th>, <td>) and columns.
It defines table structure — spanning cells across rows or columns, and connecting data cells to their headers. These attributes are central to making data tables understandable to screen-reader users.
Syntax
<td colspan="2">Spans two columns</td>
Values
| Value |
|---|
| A positive integer (default 1). |
Example
<table border="1"><tr><td colspan="2">A + B</td></tr><tr><td>A</td><td>B</td></tr></table>
Best practices
Frequently asked questions
What does the colspan attribute do?
Spans a table cell across columns.