Overview
Chirp apps serve HTML over the wire. Following accessibility best practices ensures your app works for users of assistive technologies (screen readers, keyboard navigation) and benefits all users.
This guide covers patterns aligned with WCAG (Web Content Accessibility Guidelines). For comprehensive guidance, see the WAI-ARIA Authoring Practices and MDN Accessibility.
Semantic HTML
Use elements that convey meaning:
header,main,nav,footerfor page structurearticle,sectionfor content groupingh1–h6for headings (in order, no skips)buttonfor actions,afor navigationlabelfor form controlsul/ol/lifor lists
<header>
<nav aria-label="Main navigation">...</nav>
</header>
<main>
<article aria-label="Question and answer">
<h2>Question</h2>
<p>...</p>
</article>
</main>
ARIA for Dynamic Content
When content updates via htmx or SSE, use ARIA to announce changes:
aria-live="polite"— announces updates without interruptingaria-atomic="true"— reads the entire region when it changesaria-label— describes regions and controls
The RAG demo uses this pattern for streaming answers:
<div sse-swap="answer" hx-target="this" aria-live="polite" aria-atomic="true">
<span class="thinking">Searching docs and generating answer…</span>
</div>
Forms
- Associate
labelwith inputs viafor/idor wrap the input - Use
aria-describedbyfor validation messages - Use
aria-invalidwhen a field has errors - Provide
aria-labelfor icon-only buttons
<label for="question-input">Your question</label>
<textarea id="question-input" name="question" aria-describedby="validation"></textarea>
<div id="validation" role="alert" aria-live="polite"></div>
Images and Media
- Always provide
altfor images (empty stringalt=""for decorative images) - Use
titleoraria-labelfor icon buttons
Keyboard and Focus
- Ensure all interactive elements are focusable and operable via keyboard
- Use visible focus styles (avoid
outline: nonewithout a replacement) - For custom controls (e.g. switches), use
role="switch"andaria-checked
Next Steps
- Filters — Security filters and escaping
- RAG demo — Example with ARIA and semantic structure
- WCAG Quick Reference — Full guidelines