Accessible Name Required for ARIA Treeitem
Rule ID: aria-treeitem-name
Ruleset: axe-core 4.10
User Impact: Serious
Guidelines: Deque Best Practice
How to Fix the Problem
To ensure that elements with role="treeitem"
are accessible to screen reader users, each such element must have a discernible and accessible name. This can be achieved through one of the following methods:
✅ Correct Markup Examples:
-
Using
aria-label
: -
Using
aria-labelledby
referencing another element with discernible text: -
Using inner text along with
aria-label
: -
Using the
title
attribute:
❌ Incorrect Markup Examples (Fails Accessibility):
-
Empty treeitem element:
-
Empty
aria-label
: -
aria-labelledby
pointing to non-existent ID: -
aria-labelledby
referencing an empty element:
To fix the issue:
-
Ensure all
treeitem
elements either contain visible text, or -
Use
aria-label
oraria-labelledby
with a non-empty and discernible value.
Why it Matters
Elements with role="treeitem"
represent nodes in an interactive tree structure. Without a discernible name, screen reader users cannot understand the purpose or identity of these elements. This leads to confusion and impairs navigation within tree widgets. Accessible naming is crucial for conveying the function, destination, or context of tree items, especially in complex UIs such as file explorers, menu systems, or dynamic lists.
Rule Description
Elements assigned the ARIA treeitem
role must have accessible text. This ensures the element’s purpose is clearly communicated to assistive technologies. A treeitem without a name is effectively invisible to screen reader users in terms of meaning and function.
The Algorithm (in Simple Terms)
-
Find all elements with
role="treeitem"
. -
Check if they have any of the following:
-
Non-empty inner text
-
A valid, non-empty
aria-label
-
A valid
aria-labelledby
referencing a non-empty, visible text element -
A
title
attribute that provides meaningful text
-
-
If none of these are present, the element fails the rule.