The HTML span attribute
Quick answer
The HTML span attribute specifies how many columns the element spans, for applying shared styling. It is used on the <col> and <colgroup> elements.
Overview
The span attribute spans a col/colgroup 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
<colgroup><col span="2" style="background:#eef"></colgroup>
Values
| Value |
|---|
| A positive integer (default 1). |
Best practices
Frequently asked questions
What does the span attribute do?
Spans a col/colgroup across columns.