Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 1.82 KB

require-context-role.md

File metadata and controls

60 lines (47 loc) · 1.82 KB

require-context-role

✅ The extends: 'recommended' property in a configuration file enables this rule.

<* role><* role /></*>

The required context role defines the owning container where this role is allowed. If a role has a required context, authors MUST ensure that an element with the role is contained inside (or owned by) an element with the required context role. For example, an element with role="listitem" is only meaningful when contained inside (or owned by) an element with role="list".

Roles to check

Format: role | required context role

  • columnheader | row
  • gridcell | row
  • listitem | group or list
  • menuitem | group, menu, or menubar
  • menuitemcheckbox | menu or menubar
  • menuitemradio | group, menu, or menubar
  • option | listbox
  • row | grid, rowgroup, or treegrid
  • rowgroup | grid
  • rowheader | row
  • tab | tablist
  • treeitem | group or tree

Examples

This rule allows the following:

<div role="list">
  <div role="listitem">Item One</div>
  <div role="listitem">Item Two</div>
</div>

This rule forbids the following:

<div>
  <div role="listitem">Item One</div>
  <div role="listitem">Item Two</div>
</div>

References

  1. https://www.w3.org/TR/wai-aria-1.1/#scope
  2. https://www.w3.org/TR/wai-aria-1.1/#columnheader
  3. https://www.w3.org/TR/wai-aria-1.1/#gridcell
  4. https://www.w3.org/TR/wai-aria-1.1/#listitem
  5. https://www.w3.org/TR/wai-aria-1.1/#menuitem
  6. https://www.w3.org/TR/wai-aria-1.1/#menuitemcheckbox
  7. https://www.w3.org/TR/wai-aria-1.1/#menuitemradio
  8. https://www.w3.org/TR/wai-aria-1.1/#option
  9. https://www.w3.org/TR/wai-aria-1.1/#row
  10. https://www.w3.org/TR/wai-aria-1.1/#rowgroup
  11. https://www.w3.org/TR/wai-aria-1.1/#rowheader
  12. https://www.w3.org/TR/wai-aria-1.1/#tab
  13. https://www.w3.org/TR/wai-aria-1.1/#treeitem