JavaScript Element ariaRowIndex Property

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

What You’ll Learn

Element.ariaRowIndex is an instance property that reflects the aria-rowindex attribute. Learn how it declares a cell or header’s 1-based row position within a table, grid, or treegrid, how it pairs with ariaRowCount, 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

1-based row position

04

Reflects

aria-rowindex

05

Status

Baseline widely

06

Used on

Cells / headers

Introduction

When a table or grid shows only some rows (or skips rows in a virtualized list), assistive technologies still need to know which logical row a cell belongs to.

That is what aria-rowindex communicates. The DOM property ariaRowIndex lets you read and update that position from JavaScript.

JavaScript
const el = document.getElementById("role-heading");
console.log(el.ariaRowIndex); // "1"
el.ariaRowIndex = "2";
💡
Beginner tip

Indexes are 1-based strings ("1", "2", …), not 0-based Numbers. Use ariaRowCount on the table for the total height, and ariaColIndex for the column position.

Understanding the Property

MDN: the ariaRowIndex property of the Element interface reflects the value of the aria-rowindex attribute, which defines an element’s row index or position with respect to the total number of rows within a table, grid, or treegrid.

  • Reflected attribute — mirrors aria-rowindex.
  • Get / set — readable and writable string integer.
  • 1-based — first row is "1".
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaRowIndex

Value

A string which contains an integer (the row position).

ItemDetail
Typestring containing an integer (e.g. "1", "11")
Reflectsaria-rowindex
Applies toCells / headers in table, grid, treegrid patterns
Often paired witharia-rowcount, aria-colindex

📋 Row Index on Header (MDN Shape)

MDN sets aria-rowindex="1" on the header cells (row 1 of a 100-row logical table), with body cells at indexes like 11, 16, and 18. Then it updates #role-heading from "1" to "2" via the property:

JavaScript
<table
  id="semantic-table"
  role="table"
  aria-label="Semantic Elements"
  aria-describedby="semantic_elements_table_desc"
  aria-rowcount="100"
>
  <caption id="semantic_elements_table_desc">
    Semantic Elements to use instead of ARIA's roles
  </caption>
  <thead role="rowgroup">
    <tr role="row">
      <th
        role="columnheader"
        id="role-heading"
        aria-sort="none"
        aria-rowindex="1"
      >
        ARIA Role
      </th>
      <th
        role="columnheader"
        id="element-heading"
        aria-sort="none"
        aria-rowindex="1"
      >
        Semantic Element
      </th>
    </tr>
  </thead>
  <tbody role="rowgroup">
    <tr role="row">
      <td role="cell" aria-rowindex="11">header</td>
      <td role="cell" aria-rowindex="11">h1</td>
    </tr>
    <tr role="row">
      <td role="cell" aria-rowindex="16">header</td>
      <td role="cell" aria-rowindex="16">h6</td>
    </tr>
  </tbody>
</table>
JavaScript
let el = document.getElementById("role-heading");
console.log(el.ariaRowIndex); // 1
el.ariaRowIndex = "2";
console.log(el.ariaRowIndex); // 2

Related property: ariaRowCount declares the total number of rows on the container.

⚡ Quick Reference

GoalCode / note
Readel.ariaRowIndex
Writeel.ariaRowIndex = "2"
HTML attributearia-rowindex="1"
Total rowstable.ariaRowCount (container)
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaRowIndex.

Kind
get / set

Instance

Type
string

Integer text

Reflects
aria-rowindex

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaRowIndex. Labs use a table header so you can safely read and write the property.

📚 Getting Started

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

Example 1 — Read ariaRowIndex

Log the row index from a column header.

JavaScript
const el = document.getElementById("role-heading");
console.log(el.ariaRowIndex);

// HTML includes: aria-rowindex="1"
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 row index from 1 to 2 on #role-heading.

JavaScript
let el = document.getElementById("role-heading");
console.log(el.ariaRowIndex); // 1
el.ariaRowIndex = "2";
console.log(el.ariaRowIndex); // 2
Try It Yourself

How It Works

Assigning the property updates the reflected aria-rowindex attribute. Keep indexes consistent with your logical row order in the full data set.

📈 RowCount Pair, Attribute Sync & Snapshot

Practice pairing with total rows and verify reflection.

Example 3 — Pair with ariaRowCount

Declare total rows on the table and an index on a cell.

JavaScript
const table = document.createElement("table");
table.setAttribute("role", "table");
table.ariaRowCount = "100";

const cell = document.createElement("td");
cell.setAttribute("role", "cell");
cell.ariaRowIndex = "11";
table.appendChild(cell);
document.body.appendChild(table);

console.log({
  tableRowCount: table.ariaRowCount,
  cellRowIndex: cell.ariaRowIndex
});
Try It Yourself

How It Works

The cell reports position 11 within a logical height of 100—useful when not every row is rendered in the DOM.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("th");
el.setAttribute("role", "columnheader");
el.setAttribute("aria-rowindex", "1");
document.body.appendChild(el);

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

How It Works

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

Example 5 — Support Snapshot

Feature-detect and remember the 1-based rule.

JavaScript
console.log({
  supported: "ariaRowIndex" in Element.prototype,
  tip: "1-based string integer (first row is \"1\")",
  pairsWith: "ariaRowCount on the table/grid",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Update indexes when rows are inserted, removed, or scrolled in a virtualized grid.

🚀 Common Use Cases

  • Marking headers and cells with their logical row position.
  • Virtualized grids where only a subset of rows is in the DOM.
  • Showing sparse rows (e.g. indexes 11, 16, 18) within a larger aria-rowcount.
  • Pairing with aria-colindex for full cell coordinates.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

Table declares total rows

Often via aria-rowcount / ariaRowCount.

Height
2

Cell sets ariaRowIndex

1-based position within that total.

Position
3

DOM may show a row slice

Indexes still map to the full logical grid.

Partial DOM
4

Assistive tech understands place

Users hear accurate row positions in the data set.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
  • Value is a string containing an integer for the 1-based row index.
  • Often used with aria-rowcount and cell aria-colindex.
  • Related: ariaRowCount, ariaColIndex, ariaRowIndexText, JavaScript hub.

Browser Support

Element.ariaRowIndex 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.ariaRowIndex

String integer — reflects aria-rowindex (1-based row position in table/grid/treegrid).

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 ariaRowIndex IDL — use setAttribute
No
ariaRowIndex Baseline

Bottom line: Use ariaRowIndex to get/set aria-rowindex on cells and headers. Keep 1-based string indexes aligned with your logical row set, especially for virtualized tables. Pair with ariaRowCount for the total height.

Conclusion

ariaRowIndex reflects aria-rowindex so cells and headers can declare their 1-based row position as a string integer—even when not every row is in the DOM. Update it from JavaScript when the visible slice of your data changes.

Continue with ariaRowIndexText, ariaRowCount, ariaColIndex, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use 1-based string integers that match the logical row
  • Pair with aria-rowcount on the table/grid
  • Prefer semantic <table> markup when possible
  • Update indexes when the visible row window scrolls
  • Combine with aria-colindex for cell coordinates

❌ Don’t

  • Use 0-based indexes (ARIA expects 1-based)
  • Leave stale indexes after rows move or reload
  • Treat the value as a Number type in string APIs
  • Exceed aria-rowcount with an out-of-range index
  • Forget accessible names / captions on complex tables

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaRowIndex

Reflected aria-rowindex string for 1-based row position.

5
Core concepts
📝 02

String integer

1-based row

Type
🔍 03

Cells / headers

in grids

Use
04

Baseline

widely available

Status
🎯 05

Partial DOM

still declare index

Tip

❓ Frequently Asked Questions

It reflects the aria-rowindex attribute as a string integer that defines an element’s row index or position with respect to the total number of rows in a table, grid, or treegrid.
No. MDN marks Element.ariaRowIndex as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
A string that contains an integer (for example "1" or "2"), not a Number type.
ARIA row indexes are 1-based. The first row is "1", the second is "2", and so on.
ariaRowCount is the total number of rows on the table/grid. ariaRowIndex is the position of a specific cell or header within that total.
Yes. Reading and writing ariaRowIndex updates the reflected aria-rowindex attribute.
Did you know?

MDN’s sample only renders a few body rows, but those cells use aria-rowindex values like 11, 16, and 18—so AT knows where they sit inside aria-rowcount="100".

Next: Element ariaRowIndexText

Learn the reflected aria-rowindextext property for readable row-index labels.

ariaRowIndexText →

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