# Accessibility Reference Web accessibility ensures content is usable by everyone, including people with disabilities. ## WCAG (Web Content Accessibility Guidelines) ### Levels - **A**: Minimum level - **AA**: Standard target (legal requirement in many jurisdictions) - **AAA**: Enhanced accessibility ### Four Principles (POUR) 1. **Perceivable**: Information presented in ways users can perceive 2. **Operable**: UI components and navigation are operable 3. **Understandable**: Information and UI operation is understandable 4. **Robust**: Content works with current and future technologies ## ARIA (Accessible Rich Internet Applications) ### ARIA Roles ```html
Click me
Tab 1
Item 1
``` ### ARIA Attributes ```html
Menu

Dialog Title

Description

Status updated
``` ## Keyboard Navigation ### Tab Order ```html
Not in tab order
Custom button
``` ### Keyboard Events ```javascript element.addEventListener('keydown', (e) => { switch(e.key) { case 'Enter': case ' ': // Space // Activate break; case 'Escape': // Close/cancel break; case 'ArrowUp': case 'ArrowDown': case 'ArrowLeft': case 'ArrowRight': // Navigate break; } }); ``` ## Semantic HTML ```html
  • Home
Home

Page Title

Section

Subsection

Page Title

Skipped h2

``` ## Forms Accessibility ```html
Please enter a valid email
Choose an option
Must be at least 8 characters
``` ## Images and Media ```html Sales increased 50% in Q1
Sales data visualization
Detailed description of the data...
``` ## Color and Contrast ### WCAG Requirements - **Level AA**: 4.5:1 for normal text, 3:1 for large text - **Level AAA**: 7:1 for normal text, 4.5:1 for large text ```css /* ✅ Good contrast */ .text { color: #000; /* Black */ background: #fff; /* White */ /* Contrast: 21:1 */ } /* Don't rely on color alone */ .error { color: red; /* ✅ Also use icon or text */ &::before { content: '⚠ '; } } ``` ## Screen Readers ### Best Practices ```html Skip to main content

Main heading (only one)

Read more Read more about accessibility Additional context for screen readers ``` ```css /* Screen reader only class */ .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; } ``` ## Focus Management ```css /* Visible focus indicator */ :focus { outline: 2px solid #005fcc; outline-offset: 2px; } /* Don't remove focus entirely */ /* ❌ Bad */ :focus { outline: none; } /* ✅ Good: custom focus style */ :focus { outline: none; box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.5); } ``` ```javascript // Focus management in modal function openModal() { modal.showModal(); modal.querySelector('button').focus(); // Trap focus modal.addEventListener('keydown', (e) => { if (e.key === 'Tab') { trapFocus(e, modal); } }); } ``` ## Testing Tools - **axe DevTools**: Browser extension - **WAVE**: Web accessibility evaluation tool - **NVDA**: Screen reader (Windows) - **JAWS**: Screen reader (Windows) - **VoiceOver**: Screen reader (macOS/iOS) - **Lighthouse**: Automated audits ## Checklist - [ ] Semantic HTML used - [ ] All images have alt text - [ ] Color contrast meets WCAG AA - [ ] Keyboard navigation works - [ ] Focus indicators visible - [ ] Forms have labels - [ ] Heading hierarchy correct - [ ] ARIA used appropriately - [ ] Screen reader tested - [ ] No keyboard traps ## Glossary Terms **Key Terms Covered**: - Accessibility - Accessibility tree - Accessible description - Accessible name - ARIA - ATAG - Boolean attribute (ARIA) - Screen reader - UAAG - WAI - WCAG ## Additional Resources - [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/) - [MDN Accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility) - [WebAIM](https://webaim.org/) - [A11y Project](https://www.a11yproject.com/)