Axe-core: Rule to warn about aria-label on static elements

Created on 16 May 2019  路  6Comments  路  Source: dequelabs/axe-core

Expectation:
I think a new rule to warn about aria-label on static elements would be welcome.

https://developer.paciellogroup.com/blog/2017/07/short-note-on-aria-label-aria-labelledby-and-aria-describedby/ as one example of the rules to follow.

Actual:
New rule, so nothing happens yet.

Motivation:
This tripped me up when starting out -- it's not obvious that aria-label will _not_ override the text in an element. It some cases it's easier to add aria-label than to add an additional element with sr-only, and I didn't find it intuitive as to why that'd be better.

Additionally, at least VO (Mac / iOS) does respect the aria-label as the label that's read, so it's not a consistently implemented rule and can be missed in testing.

I think an especially common case for this is with something like icon fonts.
<i class="fa fa-cog" aria-label="Settings"></i> seems like an intuitive thing to do.

help wanted rules

All 6 comments

Good idea. Seems like a good best-practice rule. Are you interested in writing the rule?

Sure, I'll try to give it a go soon!

Hey @cycomachead, just wanted to check in and see how it's going. Please let us know if you have any questions or would like some help with the rule.

@straker will this be in the next release? Should we add it to the milestone?

Verified with the latest axe-core code base,
below results for "aria-valid-attr-value" rule fails when aria-label and aria-labelledby has all possible combinations

image
and
error when generic elements use aria-label and aria-labelledy
image

Was this page helpful?
0 / 5 - 0 ratings