thedaviddias/Front-End-Checklist / skills/label-content-name-mismatch
label-content-name-mismatch
VerifiedUse when reviewing rendered HTML, interactive components, or design-system patterns related to Align visible labels with accessible names. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.9 KB |
| references/rule.md | markdown | 2.6 KB |
references/rule.md
View on GitHub# Align visible labels with accessible names
> The accessible name of a control should contain its visible label text.
**Priority:** medium · **Difficulty:** intermediate · **Time:** 10 min
---
For users of speech recognition software, the accessible name of a control must contain the text that is visible on the screen. [WCAG 2.5.3 Label in Name](https://www.w3.org/TR/WCAG21/#label-in-name) exists specifically so voice users can speak the same words they see.
## Code Examples
### Correct Implementation
```html
<!-- Visible text is part of the ARIA label -->
<button aria-label="Add item to shopping cart">Add item</button>
<!-- Preferred: Just use the visible text -->
<button>Add item</button>
```
### Incorrect Implementation
```html
<!-- Mismatch: Voice user says "Submit", but computer expects "Send" -->
<button aria-label="Send feedback">Submit</button>
```
## Why It Matters
- **Voice Control**: Users of software like Dragon NaturallySpeaking or Apple Voice Control trigger actions by speaking the visible label. If the underlying code uses a completely different name, the command will fail.
- **Consistency**: Prevents confusion for screen reader users who might be collaborating with sighted users ("Click the 'Submit' button").
- **Cognitive Ease**: Maintains a 1:1 relationship between what is seen and how the element is identified.
## Best Practices
✅ **Start with the visible text**: If you must use an `aria-label`, start it with the exact visible text.
✅ **Prefer visible text**: Whenever possible, avoid `aria-label` and rely on the actual text content of the element.
❌ **Don't use completely different labels**: Never have a visible label like "Save" and an accessible name like "Commit changes".
## Exceptions
- Evaluate the rendered experience before treating a static-code smell as a blocker; interaction timing, browser behavior, and assistive technology output often determine severity.
- Not every secondary accessibility issue deserves equal weight; prioritize the issue that most directly blocks perception, operation, or understanding.
- Avoid adding redundant markup or ARIA solely to satisfy a rule when a simpler semantic implementation would eliminate the issue entirely.
## Verification
### Automated Checks
- Inspect the browser accessibility tree or accessibility pane for the relevant element, role, or accessible name.
- Run an automated accessibility checker such as axe or Lighthouse where applicable.
### Manual Checks
- Test the affected UI with keyboard-only navigation and confirm the rule holds in the rendered experience.
- Re-test one representative user flow with a screen reader if this rule affects a key interaction.Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |