References

Beginner-friendly references for web development, with live, editable examples.

The HTML rowspan attribute

Attribute All modern browsers Updated
Quick answer

The HTML rowspan attribute makes a table cell span multiple rows. It is used on the <td> and <th> elements.

Overview

The rowspan attribute spans a table cell across rows. 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 rowspan="2">Spans two rows</td>

Values

Value
A non-negative integer (0 means span to the end of the section).

Example

Live example
<table border="1"><tr><td rowspan="2">Tall</td><td>1</td></tr><tr><td>2</td></tr></table>

Best practices

  • Set scope on every <th> so screen readers associate headers with cells.
  • Use colspan/rowspan to merge cells rather than nesting tables.
  • For complex tables, link cells to headers with the headers attribute and matching ids.
  • Add a <caption> so the table has an accessible name.

Frequently asked questions

What does the rowspan attribute do?
Spans a table cell across rows.
How do I merge table cells?
Use colspan to span columns and rowspan to span rows.
How do I make a data table accessible?
Use <th> headers with scope, add a <caption>, and link cells to headers with headers in complex tables.
Which elements use the rowspan attribute?
It is an element-specific attribute, used on table cells (<th>, <td>) and columns.