Semantics

A composite widget containing a collection of one or more rows with one or more cells where some or all cells in the grid are focusable by using methods of two-dimensional navigation, such as directional arrow keys.

Additional info from the ARIA specification

The grid role does not imply a specific visual, e.g., tabular, presentation. It describes relationships among elements. It can be used for purposes as simple as grouping a collection of checkboxes or navigation links or as complex as creating a full-featured spreadsheet application.

The cell elements of a grid have role gridcell. Authors MAY designate a cell as a row or column header by using either the rowheader or columnheader role in lieu of the gridcell role. Authors MUST ensure elements with role gridcell, columnheader, or rowheader are accessibility children of elements with role row, which are in turn are accessibility children of an element with role rowgroup, or grid.

To be keyboard accessible, authors SHOULD manage focus of descendants of a grid as described in Managing Focus. When a user is navigating the grid content with a keyboard, authors SHOULD set focus as follows:

Authors SHOULD provide a mechanism for changing to an interaction or edit mode that allows users to navigate and interact with content contained inside a focusable cell if that focusable cell contains any of the following:

For example, if a cell in a spreadsheet contains a combobox or editable text, the Enter key might be used to activate a cell interaction or editing mode when that cell has focus so the directional arrow keys can be used to operate the contained combobox or textbox. Depending on the implementation, pressing Enter again, Tab, Escape, or another key might switch the application back to the grid navigation mode.

Authors MAY use a gridcell to display the result of a formula, which could be editable by the user. In a spreadsheet application, for example, a gridcell might show a value calculated from a formula until the user activates the gridcell for editing when a textbox appears in the gridcell containing the formula in an editable state.

If aria-readonly is set on an element with role grid, user agents MUST propagate the value to all gridcell elements that are accessibility descendants of that grid and expose the value in the accessibility API. An author MAY override the propagated value of aria-readonly for an individual gridcell element.

In a grid that provides cell content editing functions, if the content of a focusable gridcell element is not editable, authors MAY set aria-readonly to true on the gridcell element. However, the value of aria-readonly, whether specified for a grid or individual cells, only indicates whether the content contained in cells is editable. It does not represent availability of functions for navigating or manipulating the grid itself.

An unspecified value for aria-readonly does not imply that a grid or a gridcell contains editable content. For example, if a grid presents a collection of elements that are not editable, such as a collection of link elements representing dates in a datepicker, it is not necessary for the author to specify a value for aria-readonly.

Authors MAY indicate that a focusable gridcell is selectable as the object of an action with the aria-selected attribute. If the grid allows multiple gridcells to be selected, the author SHOULD set aria-multiselectable to true on the element with role grid.

Since WAI-ARIA can augment an element of the host language, a grid can reuse the elements and attributes of a native table, such as an HTML table element. For example, if an author applies the grid role to an HTML table element, the author does not need to apply the row and gridcell roles to the descendant HTML tr and td elements because the user agent will automatically make the appropriate translations. When the author is reusing a native host language table element and needs a gridcell element to span multiple rows or columns, the author SHOULD apply the appropriate host language attributes instead of WAI-ARIA aria-rowspan or aria-colspan properties.

Authors SHOULD provide an accessible name for a grid, which can be done with the aria-label or aria-labelledby attribute. Authors SHOULD reference a visible label with aria-labelledby if a visible label is present for the grid.

See the ARIA Authoring Practices Guide for additional details on implementing grid design patterns.

Abstract Role

  • CompositeRepresents a container for navigating interactive descendants.

Content Categories

  • Flow ContentAn element that structures and organizes the body of a web document.

Allowed Descendants

Specific Guidance

Only row and rowgroup roles allowed.

Usage

Allowed HTML elements

Implicit semantics

  • None

Explicitly allowed

  • None

Elements that can have any role

  • abbr[role=grid]
  • address[role=grid]
  • b[role=grid]
  • blockquote[role=grid]
  • canvas[role=grid]
  • cite[role=grid]
  • code[role=grid]
  • custom-element[role=grid]
  • data[role=grid]
  • del[role=grid]
  • dfn[role=grid]
  • div[role=grid]
  • em[role=grid]
  • figure[role=grid]
  • i[role=grid]
  • ins[role=grid]
  • kbd[role=grid]
  • mark[role=grid]
  • output[role=grid]
  • p[role=grid]
  • pre[role=grid]
  • q[role=grid]
  • samp[role=grid]
  • small[role=grid]
  • span[role=grid]
  • table[role=grid]
  • tbody[role=grid]
  • tfoot[role=grid]
  • thead[role=grid]
  • time[role=grid]
  • u[role=grid]
  • var[role=grid]