roleTags
Reports ARIA roles that have semantic HTML element equivalents.
✅ This rule is included in the jsx logical preset.
Semantic HTML elements have built-in accessibility features and better browser support than generic elements with ARIA roles. Use native HTML elements when available instead of generic elements with role attributes.
Examples
Section titled “Examples”<div role="button" /><div role="img" /><span role="link" /><button /><img /><a href="#" /><div role="presentation" />When Not To Use It
Section titled “When Not To Use It”If you are using a framework that automatically manages element interactions and/or swaps elements to their semantic counterparts, you might be able to safely disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
jsx-a11y/prefer-tag-over-role - Oxlint:
jsx_a11y/prefer-tag-over-role
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.