Ask any question about HTML here... and get an instant response.
How can I create a table with headers that span multiple columns?
Asked on Oct 06, 2025
Answer
To create a table with headers that span multiple columns, you can use the
<th> element with the colspan attribute. This attribute specifies the number of columns a header should span.
<!-- BEGIN COPY / PASTE -->
<table>
<tr>
<th colspan="2">Header Spanning Two Columns</th>
</tr>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
<!-- END COPY / PASTE -->Additional Comment:
- The
colspanattribute is used in the<th>element to merge columns. - Ensure the total column count matches across all rows for consistent table structure.
- Use
<td>for regular data cells within the table.
✅ Answered with HTML best practices.
Recommended Links:
