Skip to content

Accessibility Deep Dive

Accessibility isn’t an afterthought or a nice-to-have—it’s fundamental to the web. This tutorial covers WCAG guidelines, ARIA attributes, and testing strategies to ensure your sites work for everyone.

What you’ll learn:

  • WCAG 2.1 guidelines and conformance levels
  • ARIA (Accessible Rich Internet Applications)
  • Keyboard navigation and focus management
  • Screen reader optimization
  • Color contrast and visual accessibility
  • Testing with assistive technology
  • Common accessibility patterns

Prerequisites:


WCAG (Web Content Accessibility Guidelines) is the international standard for web accessibility. It organizes requirements into four principles:

Users must be able to perceive content. Provide alternatives for non-text content:

<!-- Image with alt text -->
<img src="chart.jpg" alt="Sales growth 2020-2024: from $10k to $50k">
<!-- Video with captions -->
<video controls>
<source src="video.mp4">
<track kind="captions" src="captions.vtt">
</video>
<!-- Audio with transcript -->
<audio controls src="podcast.mp3"></audio>
<details>
<summary>Podcast transcript</summary>
<p>Full transcript text here...</p>
</details>

Users must be able to navigate and use controls. Ensure keyboard access:

<!-- All functionality available via keyboard -->
<button onclick="doSomething()">Action</button>
<!-- Focus visible on interactive elements -->
<style>
button:focus {
outline: 3px solid #0066ff;
}
</style>
<!-- Skip to main content link -->
<a href="#main" class="skip-link">Skip to main content</a>

Content must be clear and predictable:

<!-- Clear page structure -->
<h1>Main topic</h1>
<h2>Subtopic</h2>
<p>Content...</p>
<!-- Instructions provided -->
<label for="password">
Password (minimum 8 characters)
</label>
<input type="password" id="password" minlength="8">
<!-- Error messages help users fix problems -->
<input type="email" id="email" required aria-describedby="email-error">
<span id="email-error" role="alert">Invalid email format</span>

Content must work with assistive technology:

<!-- Semantic HTML -->
<button>Click me</button>
<nav>Navigation</nav>
<article>Article</article>
<!-- Proper ARIA when semantic HTML isn't enough -->
<div role="button" tabindex="0" onclick="doSomething()">
Custom button
</div>

ARIA: Accessible Rich Internet Applications

Section titled “ARIA: Accessible Rich Internet Applications”

ARIA provides additional meaning to HTML when semantic elements aren’t sufficient. ARIA has three types of attributes: roles, properties, and states.

Roles define what an element does:

Result

Properties provide additional information:

Result

States change based on user interaction:

Result

Keyboard users need to access everything via keyboard. Focus management is critical:

Result

By default, tabindex goes in source order. For complex layouts, manage focus:

<!-- Tab order: Skip decorative content -->
<button tabindex="0">Important button</button>
<img src="decoration.png" tabindex="-1" alt="">
<button tabindex="0">Another button</button>
<!-- Good: Use source order naturally -->
<form>
<label>Name: <input type="text"></label>
<label>Email: <input type="email"></label>
<button type="submit">Submit</button>
</form>

Text needs sufficient contrast with the background. WCAG requires:

  • Level A: Contrast ratio of at least 3:1
  • Level AA: Contrast ratio of at least 4.5:1 (for normal text)
  • Level AAA: Contrast ratio of at least 7:1
Result

Tools:

  • WebAIM Contrast Checker — Check contrast ratios
  • Chrome DevTools Accessibility — Built-in contrast checker
  • Lighthouse — Audits contrast issues

Screen readers announce content differently. Structure your HTML properly:

Result
<!-- Icons and decorative images -->
<img src="bullet.png" alt="">
<i class="icon-arrow" aria-hidden="true"></i>
<!-- Decorative dividers -->
<span aria-hidden="true"></span>
<!-- Good: Link text is descriptive -->
<a href="/about">Learn about our company</a>
<!-- Bad: Vague link text -->
<a href="/about">Click here</a>
<!-- Make icons accessible -->
<a href="/search" aria-label="Search the site">
<i class="icon-search"></i>
</a>

Forms are critical for accessibility:

Result

Result

  • Navigate entire page with Tab key
  • All interactive elements reachable
  • Focus indicator visible
  • No keyboard traps
  • Page structure makes sense
  • Form labels associated with inputs
  • Alt text useful (not redundant)
  • ARIA labels appropriate
  • NVDA — Free screen reader (Windows)
  • JAWS — Popular but commercial (Windows)
  • VoiceOver — Built into macOS/iOS
  • Lighthouse — Chrome DevTools auditing
  • WAVE — Browser extension for WCAG issues
  • Axe DevTools — Comprehensive accessibility testing


  • WCAG 2.1 has four principles: Perceivable, Operable, Understandable, Robust
  • Use semantic HTML first, ARIA only when needed
  • Ensure keyboard navigation with proper focus management
  • Maintain sufficient color contrast (4.5:1 minimum for normal text)
  • Label all form inputs with <label> elements
  • Provide alt text for all images
  • Test with keyboard navigation and screen readers
  • Use skip links and landmark regions

SEO Optimization

Advanced technical SEO with HTML. Continue →

Custom Elements

Introduction to Web Components and custom elements. Continue →