Special Offer Diwali Special Bundle Offer: 3 courses for ₹8,999, save ₹9,001 (50% OFF)! Limited seats available. View Bundles →
0% Completed
Tutorials / HTML Tutorial / Chapter 5: Modern HTML5, Media & Best Practices
HTML ⏱ 10 min read

Web Accessibility (a11y) & ARIA

The web is for everyone. Building accessible websites ensures people with disabilities, visual impairments, or motor challenges can learn and navigate seamlessly.

What is it?

Web accessibility (often abbreviated as a11y) is the practice of designing websites that people with disabilities can use with assistive technologies (like screen readers). ARIA (Accessible Rich Internet Applications) provides extra attributes to bridge gaps in complex dynamic UIs.

Why is it used?

Accessible websites are legally required in many jurisdictions, improve usability for all users (e.g. keyboard navigation), and rank higher on search engines.

Detailed Explanation

Core Accessibility Principles: 1. Semantic HTML First: Native elements (`<button>`, `<a>`, `<input>`) have keyboard accessibility built-in. Never use a `<div>` where a `<button>` belongs! 2. Contrast: Maintain at least 4.5:1 text-to-background contrast ratio. 3. Keyboard Navigability: Every interactive element must be reachable using the Tab key. 4. ARIA Attributes: Use `aria-label`, `aria-expanded`, `aria-hidden` when visual meaning is not apparent to screen readers.

Syntax Structure

Syntax Blueprint
<!-- Accessible Button with Icon -->
<button type="button" aria-label="Close Navigation Menu">
  <svg aria-hidden="true">...</svg>
</button>

Code Example

HTML Code
<!-- Accessible Accordion / Toggle -->
<section aria-labelledby="faq-heading">
  <h2 id="faq-heading">Frequently Asked Questions</h2>
  
  <div class="faq-item">
    <button 
      type="button" 
      class="faq-trigger" 
      aria-expanded="false" 
      aria-controls="faq-answer-1"
      id="faq-btn-1"
    >
      Do you provide MKCL KLiC course certificates?
    </button>
    <div 
      id="faq-answer-1" 
      class="faq-content" 
      role="region" 
      aria-labelledby="faq-btn-1" 
      hidden
    >
      <p>Yes, all successful students receive official, government-recognized MKCL KLiC certificates.</p>
    </div>
  </div>
</section>

Explanation of the Code

• `aria-expanded="false"` informs screen readers whether the accordion drawer is open or closed. • `aria-controls` establishes the programmatic connection between button and content. • `aria-hidden="true"` hides decorative icons from screen reader clutter.

Expected Output

An interactive accordion component that screen-reader users can understand and operate via keyboard Tab and Enter keys.

Real-World Application

Major enterprises (Google, Microsoft, Apple, government portals) conduct rigorous automated and manual accessibility audits before launching any feature.

Common Mistakes to Avoid

• Creating clickable divs (`<div onclick="...">`) without keyboard tabindex or enter key handling. • Stripping CSS outline on `:focus` states, making keyboard navigation impossible.

Quick Practice Challenge

Take an icon-only search button and make it accessible using `aria-label` and `aria-hidden` on the icon.

Key Takeaways

• Semantic HTML has accessibility built-in; prefer `<button>` over clickable `<div>`. • Always maintain visible keyboard focus outlines. • Use ARIA attributes (`aria-label`, `aria-expanded`) to describe dynamic widgets.