JavaScript Element ariaRowSpan Property

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline
Instance property

What You’ll Learn

Element.ariaRowSpan is an instance property that reflects the aria-rowspan attribute. Learn how it declares how many rows a cell or gridcell spans, how it relates to HTML rowspan and ariaRowIndex, and how to get or set it from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String (integer)

03

Meaning

Rows spanned

04

Reflects

aria-rowspan

05

Status

Baseline widely

06

Used on

Cell / gridcell

Introduction

Some table cells stretch across more than one row—like a category label that sits beside several data rows. Assistive technologies need that height as part of the grid model.

aria-rowspan declares the span count. The DOM property ariaRowSpan lets you read and update it from JavaScript.

JavaScript
const el = document.getElementById("spanning-heading");
console.log(el.ariaRowSpan); // "3"
el.ariaRowSpan = "2";
💡
Beginner tip

On a native HTML table, prefer the HTML rowspan attribute for layout. Use ariaRowSpan for ARIA grids / treegrids, or when you need the reflected ARIA value in script.

Understanding the Property

MDN: the ariaRowSpan property of the Element interface reflects the value of the aria-rowspan attribute, which defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.

  • Reflected attribute — mirrors aria-rowspan.
  • Get / set — readable and writable string integer.
  • Span height — how many rows the cell covers.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaRowSpan

Value

A string which contains an integer (the number of rows spanned).

ItemDetail
Typestring containing an integer (e.g. "3")
Reflectsaria-rowspan
Applies tocell / gridcell (table, grid, treegrid)
HTML cousinrowspan on <td> / <th>

📋 Spanning Heading (MDN Shape)

MDN starts with a heading spanning 3 rows, then updates ariaRowSpan to "2":

JavaScript
<table>
  <thead>
    <tr>
      <th id="spanning-heading" rowspan="3" aria-rowspan="3">
        Spanning heading
      </th>
      <th>Heading</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>One</td>
    </tr>
    <tr>
      <td>Two</td>
    </tr>
  </tbody>
</table>

Related: ariaRowIndex (starting row) and ariaRowCount (total rows). Also see ariaColSpan for the column-direction twin.

⚡ Quick Reference

GoalCode / note
Readel.ariaRowSpan
Writeel.ariaRowSpan = "2"
HTML attributearia-rowspan="3"
Native table layoutrowspan="3" on <th> / <td>
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaRowSpan.

Kind
get / set

Instance

Type
string

Integer text

Reflects
aria-rowspan

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaRowSpan. Labs use a spanning table heading so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s span update.

Example 1 — Read ariaRowSpan

Log the span count from a merged heading cell.

JavaScript
const el = document.getElementById("spanning-heading");
console.log(el.ariaRowSpan);

// HTML includes: aria-rowspan="3"
Try It Yourself

How It Works

The property returns the attribute string. If the attribute is missing, many browsers return null.

Example 2 — MDN Update to "2"

MDN: change the span from 3 to 2.

JavaScript
let el = document.getElementById("spanning-heading");
console.log(el.ariaRowSpan); // 3
el.ariaRowSpan = "2";
console.log(el.ariaRowSpan); // 2
Try It Yourself

How It Works

Assigning the property updates the reflected aria-rowspan attribute. For native layout, also keep HTML rowspan in sync if you rely on it for rendering.

📈 Index Pair, Attribute Sync & Snapshot

Practice pairing with row index and verify reflection.

Example 3 — Pair with ariaRowIndex

Declare starting row and how many rows the cell covers.

JavaScript
const cell = document.createElement("td");
cell.setAttribute("role", "cell");
cell.ariaRowIndex = "1";
cell.ariaRowSpan = "2";
document.body.appendChild(cell);

console.log({
  start: cell.ariaRowIndex,
  span: cell.ariaRowSpan,
  coversThrough: "rows 1 and 2"
});
Try It Yourself

How It Works

Index is where the cell starts; span is how tall it is. Keep both consistent with ariaRowCount on the table/grid.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("th");
el.setAttribute("aria-rowspan", "3");
document.body.appendChild(el);

el.ariaRowSpan = "2";
console.log({
  fromProperty: el.ariaRowSpan,
  fromAttribute: el.getAttribute("aria-rowspan"),
  same: el.ariaRowSpan === el.getAttribute("aria-rowspan")
});
Try It Yourself

How It Works

Prefer ariaRowSpan in script; keep the attribute for HTML markup.

Example 5 — Support Snapshot

Feature-detect and remember HTML rowspan vs ARIA.

JavaScript
console.log({
  supported: "ariaRowSpan" in Element.prototype,
  tip: "Prefer HTML rowspan for native tables; ariaRowSpan for ARIA grids",
  valueType: "string integer",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Do not let ARIA span disagree with the visual layout—mismatched spans confuse AT users.

🚀 Common Use Cases

  • Merged cells in ARIA grids and treegrids (vertical merges).
  • Updating span height when a custom grid layout changes.
  • Keeping ARIA in sync with HTML rowspan on hybrid tables.
  • Pairing with ariaRowIndex for start + height.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

Cell starts at a row

Often described with ariaRowIndex.

Start
2

ariaRowSpan sets the height

How many rows the cell covers.

Span
3

Visual layout should match

HTML rowspan or grid CSS must agree.

UI
4

Assistive tech understands merges

Users hear accurate cell span information.

📝 Notes

Browser Support

Element.ariaRowSpan is Baseline Widely available (MDN: across browsers since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline Widely available

Element.ariaRowSpan

String integer — reflects aria-rowspan (rows spanned by a cell).

Baseline Widely available
Google Chrome Supported (ARIA reflection)
Yes
Microsoft Edge Supported (ARIA reflection)
Yes
Mozilla Firefox Supported (ARIA reflection)
Yes
Apple Safari Supported (ARIA reflection)
Yes
Opera Follow Chromium support
Yes
Internet Explorer No ariaRowSpan IDL — use setAttribute
No
ariaRowSpan Baseline

Bottom line: Use ariaRowSpan to get/set aria-rowspan. Keep the span aligned with visual layout (HTML rowspan or grid CSS). Pair with ariaRowIndex and ariaRowCount for a complete row model.

Conclusion

ariaRowSpan reflects aria-rowspan so cells and gridcells can declare how many rows they span. Use string integers, keep visuals in sync, and prefer HTML rowspan for simple native tables when that is enough.

Continue with ariaSelected, ariaRowIndex, ariaColSpan, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use string integers for the span count
  • Match ARIA span to the visual merge
  • Pair with ariaRowIndex when needed
  • Prefer HTML rowspan on native tables
  • Stay within ariaRowCount bounds

❌ Don’t

  • Leave ARIA span out of sync with layout
  • Treat the value as a Number type in ARIA APIs
  • Span past the declared row total
  • Rebuild native tables with ARIA without need
  • Forget to update span when merges change

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaRowSpan

Reflected aria-rowspan string for how many rows a cell covers.

5
Core concepts
📝 02

String integer

span count

Type
🔍 03

Cell / gridcell

table / grid

Use
04

Baseline

widely available

Status
🎯 05

vs rowspan

HTML for layout

Tip

❓ Frequently Asked Questions

It reflects the aria-rowspan attribute as a string integer that defines how many rows a cell or gridcell spans in a table, grid, or treegrid.
No. MDN marks Element.ariaRowSpan as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
A string that contains an integer (for example "2" or "3"), not a Number type.
On a native <td>/<th>, HTML rowspan is the standard way to span rows. aria-rowspan / ariaRowSpan is the ARIA reflection used especially for ARIA grid/treegrid widgets (and can mirror rowspan).
ariaRowCount is the total rows. ariaRowIndex is a cell’s starting row. ariaRowSpan is how many rows that cell covers from that position.
Yes. Reading and writing ariaRowSpan updates the reflected aria-rowspan attribute.
Did you know?

MDN’s demo sets both HTML rowspan="3" and aria-rowspan="3" on the same heading—layout via HTML, ARIA reflection via the attribute/property.

Next: Element ariaSelected

Learn the reflected aria-selected property for tabs, options, and selectable items.

ariaSelected →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful