References

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

The HTML aria-rowcount attribute

ARIA Accessibility All modern browsers Updated
Quick answer

The aria-rowcount attribute states the total number of rows in a table, grid or treegrid when the DOM contains only some of them. Value: an integer, or -1 if unknown. Pair it with aria-rowindex.

Overview

The aria-rowcount attribute defines the total number of rows in a table, grid or treegrid.

It exposes table or grid structure to assistive technology. You generally only need it when you build a custom grid (role="grid") or when a native <table> cannot express the structure — for example a grid whose rows are virtualized and not all present in the DOM. A real <table> with <th> headers conveys most of this automatically.

Like all ARIA, aria-rowcount changes only the accessibility tree — what assistive technology perceives — never the element's behavior or appearance. The first rule of ARIA applies: if a native HTML element or attribute conveys this, use that instead, and only reach for ARIA when nothing native fits.

Syntax

<table role="grid" aria-rowcount="1000"> … </table>

Values

Value
An integer (use -1 if the total is unknown).

Example

Live example
<table role="grid" aria-rowcount="1000"> … </table>

Best practices

  • Follow the first rule of ARIA — use a native HTML element or attribute that conveys this where one exists, rather than adding ARIA.
  • Use a native <table> with <th> headers where possible — it conveys most structure for free.
  • Reach for these attributes on a custom grid, or when rows and columns are not all in the DOM.
  • Keep the index and count values accurate as the grid changes.

Frequently asked questions

What does aria-rowcount do?
Defines the total number of rows in a table, grid or treegrid.
Do I need ARIA table attributes on a normal table?
No. A native <table> with proper <th> headers already exposes its structure. These are for custom or virtualized grids.
When are the index attributes needed?
When a grid is virtualized — only some rows or columns are in the DOM — so the browser cannot compute the real position.
Do I need aria-rowcount if native HTML already conveys it?
Usually not. ARIA is for what native HTML cannot express; redundant or incorrect ARIA can make accessibility worse. Reach for it only when no native element fits.