Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aria-label should only be applied to semantic elements #2498

Open
alundgard opened this issue Jul 30, 2024 · 1 comment
Open

Aria-label should only be applied to semantic elements #2498

alundgard opened this issue Jul 30, 2024 · 1 comment
Labels

Comments

@alundgard
Copy link
Member

alundgard commented Jul 30, 2024

Current behavior

aria-label is applied to non-semantic HTML elements (span, div) without an appropriate role attribute.

Steps to reproduce

Example A page: Spotlight Accessibility for SODA - San Francisco Buildings.
Inspect the pagination ("Previous" and "Next" navigation) at the bottom of the page.

Example B page: Example page: Parker Library - Search Results.
Inspect the highlighted "1" in the pagination ("Previous" or "Next") navigation at the bottom of the page.

Possible solution

Note: This issue is similar to #2500.

WCAG Level A: What happens when aria-label, aria-labelledby and aria-describedby are on static HTML elements?

See SODA's recommendations below.

Reported by SODA

Violation: Ensure ARIA roles, states, and properties are valid
Severity: Minor

[Issue]
Some elements contain invalid ARIA attributes or values (states, roles, and properties). Aria-label is not usable on an element that has no semantic meaning (SPAN, DIV, etc.).

[User Impact]
When ARIA attributes (state, roles, and properties) are not valid according to the specification or are not used correctly, assistive technology may not function as expected.

Example A page:

[Code Reference]
<span aria-current="true" aria-label="Current Page, Page 1" class="page-link">1</span>

[Recommendation]
Multiple solutions are possible. It is possible to use offiscreen text in replacement of the aria label such as <span>1<span class="sr-only"> Current Page</span></span>

It is also possible to use an anchor () that links to the same page and use the aria-label on that instead.

Other options are possible.

Example B page:

[Code Reference]

<li class="page-item active">
        <span class="page-link" aria-label="Current Page, Page 1" aria-current="true">1</span>
</li>

[Recommendation]
There are multiple possible solutions. One of the simpliest may be to add an aria-label on the that indicates the state, such as

<a aria-label="Gallery: Currently Selected">
Another solution is to use aria-current.

<a aria-current="true">

@alundgard alundgard added the a11y label Jul 30, 2024
@alundgard alundgard changed the title Aria-label should only apply to elements with semantic meaning Aria-label should only be applied to semantic elements Jul 30, 2024
@jcoyne
Copy link
Contributor

jcoyne commented Jul 31, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants