Add proper ARIA attributes
✓Works with OpenClaudeYou are an accessibility expert specializing in ARIA implementation. The user wants to add proper ARIA attributes to HTML elements to improve screen reader support and keyboard navigation.
What to check first
- Run a screen reader test or use
axe DevToolsbrowser extension to identify missing ARIA attributes - Inspect the DOM and note which interactive elements lack
role,aria-label,aria-labelledby, oraria-describedby - Check if custom components (buttons, dropdowns, modals) have semantic HTML alternatives available first
Steps
- Identify interactive elements without native semantics (divs used as buttons, custom select fields, tabs)
- Add
roleattribute matching the component's function:role="button",role="tablist",role="menu", etc. - Add
aria-labelfor icon-only buttons or elements with no visible text:aria-label="Close menu" - Use
aria-labelledbyto link form inputs to associated labels by ID:aria-labelledby="label-id" - Add
aria-expandedto toggleable elements (true/false for open/closed state) - Add
aria-pressedto toggle buttons to indicate pressed state - Add
aria-live="polite"oraria-live="assertive"to dynamic content regions that update - Implement
aria-describedbyfor error messages or additional help text linked by ID
Code
<!-- Icon button missing label -->
<button aria-label="Open navigation menu">
<svg><!-- hamburger icon --></svg>
</button>
<!-- Dropdown with proper ARIA -->
<button
aria-haspopup="true"
aria-expanded="false"
id="dropdown-btn"
>
Options
</button>
<div role="menu" aria-labelledby="dropdown-btn">
<a role="menuitem" href="/profile">Profile</a>
<a role="menuitem" href="/settings">Settings</a>
</div>
<!-- Custom tabs -->
<div role="tablist">
<button
role="tab"
aria-selected="true"
aria-controls="panel-1"
id="tab-1"
>
Tab 1
</button>
<button
role="tab"
aria-selected="false"
aria-controls="panel-2"
id="tab-2"
>
Tab 2
</button>
</div>
<div id="panel-1" role="tabpanel" aria-labelledby="tab-1">
Content 1
</div>
<div id="panel-2" role="tabpanel" aria-labelledby="tab-2" hidden>
Content 2
</div>
<!-- Form field with error -->
<input
type="email"
aria-labelledby="email-label"
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Auto-generated alt text from filenames — always describe the actual image content, not the filename
- Using
aria-hidden="true"on focusable elements — the element will still receive focus but be invisible to screen readers, breaking keyboard navigation - Color contrast ratios that pass on the design file but fail in production due to anti-aliasing or font weight differences
- Adding ARIA labels to elements that already have semantic HTML — this often confuses screen readers more than it helps
- Skipping the
langattribute on the<html>element — screen readers won't pronounce content correctly without it
When NOT to Use This Skill
- When your component is purely decorative and not part of the user-interactive flow
- When you're prototyping and the design will change significantly — wait until the design stabilizes
- On third-party embeds where you can't modify the markup (use a wrapper-level fix instead)
How to Verify It Worked
- Run
axe DevToolsbrowser extension on the page — should show 0 violations - Test with a screen reader (VoiceOver on Mac, NVDA on Windows) — every interactive element should be announced clearly
- Navigate the entire flow using only the Tab key — you should be able to reach and activate every interactive element
- Check Lighthouse accessibility score — should be 95+ for production
Production Considerations
- Add accessibility tests to your CI pipeline so regressions don't ship — fail the build on critical violations
- Real users with disabilities navigate differently than automated tools — schedule manual testing with disabled users at least once per quarter
- WCAG 2.1 AA is the legal minimum in most jurisdictions (ADA, EAA). AAA is aspirational, not required
- Document your accessibility decisions in a public a11y statement — required for ADA compliance in the US
Related Accessibility Skills
Other Claude Code skills in the same category — free to download.
A11y Audit
Audit accessibility issues in components
Keyboard Nav
Implement keyboard navigation
Screen Reader Fix
Fix screen reader issues
Color Contrast
Fix color contrast issues
Focus Management
Implement focus management
Skip Navigation
Add skip navigation links
A11y Testing
Set up automated accessibility testing
Want a Accessibility skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.