role="tree": aria-selected is required for selectable items
- Dominant language
- Markdown
- Stars
- 11k
- Forks
- 23.2k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 331
Description
### MDN URL
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tree_role
### What specific section or headline is this issue about?
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tree_role#single_and_multiple_select_trees
### What information was incorrect, unhelpful, or incomplete?
The tree_role page says:
> In single-select trees, [aria-selected](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-selected) is set to true for the selected tree items and it is not present on any other tree item in the tree.
However, the treeitem_role page [says](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/treeitem_role#:~:text=All%20nodes%20that,node%20is%20selectable.):
> All nodes that are selectable but not selected have either aria-selected or aria-checked set to false. If the tree contains nodes that are not selectable, do not include either aria-selected or aria-checked, as the presence of either attribute indicates to assistive technologies the node is selectable.
This guidance is specifically in a paragraph about single-select trees, as multi-select trees are not mentioned until the following paragraph.
### What did you expect to see?
These two pages contradict each other and I'm not totally sure which is correct. I think the treeitem guidance is correct, based on the below evidence. So the tree page should either not say anything about how to set `aria-selected` (since that is addressed on the `treeitem` page) or it should state the same guidance that the `treeitem` page gives, which is that `aria-selected` should be set to false on all selectable but not currently selected items.
### Do you have any supporting links, references, or citations?
- The [aria-selected spec](https://www.w3.org/TR/wai-aria-1.2/#aria-selected) says that `selected=false` means it's not currently select**ed**, while `undefined` means it's not select**able**.
- The [treeitem spec](https://www.w3.org/TR/wai-aria-1.2/#treeitem) says that the `aria-selected` attribute is required.
### Do you have anything more you want to share?
I would be happy to propose the changes myself once I get confirmation about which page is correct.
### MDN metadata
Page report details
* Folder: `en-us/web/accessibility/aria/reference/roles/tree_role`
* MDN URL: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tree_role
* GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/accessibility/aria/reference/roles/tree_role/index.md
* Last commit: https://github.com/mdn/content/commit/a8b25483994fa47cf949b432ddf34a6bce2ddb2e
* Document last modified: 2025-05-12T15:08:46.000Z
Contributor guide
Assessment
This issue has not been assessed yet.