大网数据广告活动
Web 标准与前端开发

ARIA: aria-rowcount attribute

· 52CE 我爱测

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

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

Description

Some tables have hundreds, even millions, of rows. Even for tables with fewer rows, loading only a subsection of rows may be a design requirement, improve performance, or improve user experience. When only a subset of rows are loaded, you do need to let all users know that only a subset of the data is being displayed. The aria-rowcount attribute is used to define the total number of rows in a table, grid, or treegrid.

Included on the table element or on an element with a role of table, the value is the number of rows in the full table, as an integer. If the total number of rows is not known, include aria-rowcount="-1", which tells the browser to not count the total number of rows.

If all of the rows are loaded and in the DOM, you don't need to include aria-rowcount as browsers automatically count the total number of rows. However, if the rows aren't all present in the DOM at any time, this attribute is needed to provide the number of rows when the full table size is known and to tell the browser to not automatically count the rows when the total number of rows is not known.

Example

The following example shows a grid with 24 rows, of which the first row and rows 7 through 9 are displayed to the user.

<div role="grid" aria-rowcount="24">
  <div role="rowgroup">
    <div role="row" aria-rowindex="1">
      <span role="columnheader">First Name</span>
      <span role="columnheader">Last Name</span>
      <span role="columnheader">Position</span>
    </div>
  </div>
  <div role="rowgroup">
    <div role="row" aria-rowindex="7">
      <span role="gridcell">Morgan</span>
      <span role="gridcell">Brian</span>
      <span role="gridcell">Midfielder</span>
    </div>
    <div role="row" aria-rowindex="8">
      <span role="gridcell">Abby</span>
      <span role="gridcell">Dahlkemper</span>
      <span role="gridcell">Defender</span>
    </div>
    <div role="row" aria-rowindex="9">
      <span role="gridcell">Ashlyn</span>
      <span role="gridcell">Harris</span>
      <span role="gridcell">Goalkeeper</span>
    </div>
  </div>
</div>

Values

  • <integer>
    • : The number of rows in the full table or -1 is the table size is not known.

Associated interfaces

  • Element.ariaRowCount
    • : The ariaRowCount property, part of the Element interface, reflects the value of the aria-rowcount attribute.
  • ElementInternals.ariaRowCount
    • : The ariaRowCount property, part of the ElementInternals interface, reflects the value of the aria-rowcount attribute.

Associated roles

Used in roles:

Inherited into roles:

Specifications

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。