Accessibility with ARIA Attributes
Implements accessible web components using ARIA attributes, proper roles, keyboard navigation support, and screen reader announcements.
Code
<div class="accordion">
<h3>
<button aria-expanded="true"
aria-controls="panel-1"
id="header-1">
Section 1
</button>
</h3>
<div role="region"
aria-labelledby="header-1"
id="panel-1">
<p>Content for section 1</p>
</div>
</div>
<div class="alert" role="alert" aria-live="assertive">
Form submitted successfully!
</div>
<nav aria-label="Main navigation">
<ul>
<li><a href="/" aria-current="page">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<button aria-busy="false"
aria-describedby="save-help">
Save Changes
</button>
<span id="save-help" class="visually-hidden">
Saves all changes to your profile
</span>
<div role="status" aria-live="polite" class="sr-only">
Loading content...
</div>
<input type="text"
aria-label="Search products"
aria-describedby="search-hint"
placeholder="Search...">
<p id="search-hint">Type at least 3 characters</p>ARIA attributes enhance accessibility: aria-expanded/aria-controls for expandable UI, role="alert"/aria-live for dynamic announcements, aria-current for navigation state, aria-busy for loading states, aria-label/aria-describedby for additional context. Use semantic HTML first, then ARIA for gaps. visually-hidden class hides content visually while keeping it accessible to screen readers.
Interactive Tools for This Topic
WCAG Color Contrast CheckerCalculate WCAG 2.1 color contrast ratios between foreground and background colors. Verify AA and AAA compliance levels for normal and large text accessibility.JSON to Zod Schema ConverterInfer typed Zod z.object schemas from JSON payloads locally, supporting nested objects, merged array shapes, enums, nullable fields, and JSDoc comments.JSON Schema ValidatorValidate JSON data against a JSON Schema definition and get detailed error reports. Supports type checking, required fields, and common constraint validation.JSONL / NDJSON InspectorValidate NDJSON and JSON Lines line-by-line, pinpoint syntax errors by line number, analyze key frequencies and types, and export a pretty JSON array.
Report a problem with this exampleOpens a pre-filled issue on GitHub.