TL;DR
Using aria-label or aria-labelledby on static text elements like <div> or <span> is a common accessibility mistake. These attributes should only be applied to interactive elements or when roles are changed.
✦ Why It Matters
Review your code to ensure aria-label and aria-labelledby are only used on interactive elements or appropriately role-changed elements.
Key Takeaways
Full Summary
Accessibility in web development often suffers from the misuse of aria-label and aria-labelledby attributes on static text elements such as <div>, <span>, <p>, <strong>, and <em>. These attributes are designed for interactive elements like buttons and links, and their application on non-interactive elements is generally invalid unless the element's role is explicitly changed.
Most screen readers will not announce these invalid labels, rendering them ineffective. The article emphasizes that developers should avoid using these attributes on static text to prevent confusion and ensure proper accessibility.
Instead, focus on applying aria-labels only to elements that require them, such as form controls or navigational landmarks. This approach not only enhances user experience for those relying on assistive technologies but also aligns with best practices in web accessibility.
Related