Accessibility (a11y) Cheat Sheet

Quick reference guide for Web Accessibility (a11y): ARIA roles, screen reader attributes, focus management, and keyboard navigation.

Web & Network
accessibility
a11y
aria

Web Accessibility (a11y) ensures that websites and applications are usable by everyone, including people with visual, auditory, motor, or cognitive disabilities.

Essential ARIA Attributes

Table
ARIA AttributePurposeExample Usage
aria-labelProvide invisible accessible name string<button aria-label="Close dialog">X</button>
aria-labelledbyReference ID of element acting as label<div aria-labelledby="heading-id">
aria-describedbyReference ID of extra hint text element<input aria-describedby="hint-id" />
aria-expandedIndicate open/closed state of dropdowns<button aria-expanded="true">Menu</button>
aria-hiddenHide decorative element from screen readers<svg aria-hidden="true">...</svg>
aria-liveAnnounce dynamic updates (polite / assertive)<div aria-live="polite">Item saved</div>

Accessible Form Controls & Landmarks

html
<!-- Semantic Landmark Navigation -->
<header role="banner">
  <nav aria-label="Main Navigation">
    <ul><li><a href="/">Home</a></li></ul>
  </nav>
</header>

<main id="main-content">
  <!-- Accessible Button Trigger -->
  <button type="button" aria-haspopup="dialog" aria-controls="modal-1">
    Open Settings
  </button>
</main>

Focus Management & Keyboard Navigation

Table
Element / KeyExpected Behavior
tabindex="0"Make non-interactive element focusable in normal tab order
tabindex="-1"Programmatically focusable via JS (element.focus()), skipped by Tab key
Tab / Shift+TabNavigate forward / backward through focusable controls
EscapeClose active modal dialog or popup menu
Space / EnterActivate focused button or toggle checkbox

Common Pitfalls & Tips

[!WARNING] Do not use <div> or <span> as click triggers without adding role="button", tabindex="0", and keydown event handlers for Space/Enter keys!

[!TIP] Always prefer native semantic HTML elements (<button>, <header>, <nav>, <main>) over ARIA attributes whenever possible.