Visible label missing from the accessible name
A button showing 'Search' with aria-label 'Find products' may not respond when a user speaks its visible label. squirrel compares the two.
What label in name means
Voice control users say what they see: “click Search”. The software matches the spoken words against the control’s accessible name, not against the pixels. When the name does not contain the visible words that command fails, with no error explaining why, and the user has to find another way in.
WCAG success criterion 2.5.3 Label in Name, Level A, requires the visible label text to be part of the accessible name. Adding context around it is fine; replacing it is not.
What squirrel checks
One check, label-content-name-mismatch, at severity error. It looks at elements carrying both an aria-label and visible text: button, a, input, select, and anything with role="button" or role="link".
Visible text is gathered by walking the element’s child nodes, skipping any subtree marked aria-hidden="true" or carrying the hidden attribute. Both strings are lowercased and their whitespace collapsed before comparison.
Two kinds of control are left out. Visible text with no letter or digit (✕, ×, ✖, ☰, ›, punctuation, emoji) is a symbol used as an icon, not a label a user would speak, so it is not compared with the accessible name: <button aria-label="Schließen">✕</button> passes. WCAG 2.5.3 excludes symbolic characters, and a symbol next to real text still counts, since the whole visible text is compared. A control that is not rendered (a hidden or display:none ancestor, an aria-hidden ancestor, a closed <dialog>, a <style> rule squirrel can decide) is out of the accessibility tree and is skipped. A control a style may hide but squirrel cannot settle (a pseudo-class, a media query, a page that also loads an external stylesheet) is reported as label-content-name-mismatch-unconfirmed, a warning, not as a failure.
- Fail when the
aria-labeldoes not contain the visible text as a substring. Report message:N element(s) where visible text doesn't match accessible name. Items readbutton: visible="search" vs aria-label="find products", truncating each side at 20 characters, up to ten with a count of the rest. The finding carries the issueVoice control users may not be able to activate these controls. - Pass with
Visible labels match accessible names. - Info with
No elements with aria-label and visible text found.
How to fix it
<button aria-label="Search products">Search</button>Start the aria-label with the visible words and add the extra context after them. That satisfies both the voice command and the screen reader.
A badge inside the control is the usual false positive. <button aria-label="Notifications">Notifications <span>3</span></button> has visible text “notifications 3”, which the label does not contain. Mark the badge aria-hidden="true", or include the count in the label.
| Rule ID | a11y/label-content-name-mismatch |
| Category | Accessibility |
| Scope | Per-page |
| Severity | error |
| Weight | 7/10 |
Enable / disable
Disable this rule
[rules]
disable = ["a11y/label-content-name-mismatch"]Disable all Accessibility rules
[rules]
disable = ["a11y/*"]Enable only this rule
[rules]
enable = ["a11y/label-content-name-mismatch"]enable replaces the default ["*"], so this is the only rule selected. Leave disable out: a rule that matches any disable pattern is skipped even when enable names it. Only an enabled setting under a rule’s own [rule_options] table overrides both lists.
Related rules
- a11y/button-name: controls with no accessible name at all.
- a11y/link-text: link names that exist but say nothing useful.
- a11y/aria-labels: where
aria-labelis the right answer rather than the problem. - a11y/form-field-multiple-labels: two labels competing to name one control.
Accessibility findings ship in every audit next to the SEO, performance and agent experience rules. See Website security scan with AI for how an agent works through a report.
Glossary: Accessible name.
References
- Understanding SC 2.5.3 Label in Name, W3C
- aria-label, MDN
- Accessible name and description computation, W3C
Check your site
Run squirrel audit https://example.com and open the Accessibility section of the report. Each finding shows the visible text and the accessible name side by side. Signed-out local audits need no account and cost nothing. Signed-in audits spend credits.