Accessibility (a11y)
Include everyone — build for screen readers, keyboard users, and people with disabilities.
Imagine a metro station lift — wheelchair users, blind users, elderly users — everyone should be able to use it. Buttons have Braille, audio announcements play, wide doors. That's accessibility — designing for everyone, not just the majority.
Web accessibility means building websites that people with disabilities can use — blind (screen readers), deaf (captions), motor impaired (keyboard only), color blind (contrast), cognitive (clear language). WCAG (Web Content Accessibility Guidelines) is the standard — Level A, AA, AAA. India's RpDAA 2016 mandates government websites be accessible.
Core accessibility tools and attributes:
- alt attribute — Text description for images.
<img src="charminar.jpg" alt="Charminar at night">. Missing alt = screen reader says "image" only. Empty altalt=""= decorative image. - aria-label — Invisible label only screen readers see.
<button aria-label="Close menu">✕</button>. Essential for icon buttons. - aria-labelledby — Use another element's ID as label.
<h2 id="title">Biryani</h2> <div aria-labelledby="title">. - aria-describedby — Link to description element.
<input aria-describedby="help"> <p id="help">Min 8 characters</p>. - aria-hidden="true" — Hide from screen readers. Decorative icons. ⚠️ Never put focusable elements inside.
- role attribute — Tell screen reader what the element is. Only for custom widgets — semantic elements already have implicit roles.
- aria-expanded — Accordion/menu open state.
<button aria-expanded="false">Menu</button>. - aria-live — Announce dynamic content.
"polite"= waits for pause,"assertive"= interrupts immediately. - tabindex —
tabindex="0"= add to tab order.tabindex="-1"= programmatic focus only.tabindex="1+"= AVOID. - label + for — Connect labels to form inputs.
<label for="email">Email</label> <input id="email">. - Color Contrast — WCAG AA = 4.5:1 ratio (normal text), 3:1 (large text). Gray on white = often fails.
- Semantic HTML —
<nav>,<main>,<article>,<section>— gives structure to screen readers.
<!-- Image with proper alt -->
<img src="biryani.jpg" alt="Hyderabadi Biryani on steel plate with raita">
<!-- Icon button with aria-label -->
<button aria-label="Close notification">✕</button>
<!-- Live region for dynamic content -->
<div aria-live="polite" id="cart">3 items in cart</div>
<!-- Form with proper labels -->
<label for="name">Your Name</label>
<input type="text" id="name" name="name" aria-required="true">
<!-- Keyboard-accessible custom button -->
<div role="button" tabindex="0"
aria-label="Add to cart"
onclick="addToCart()"
onkeydown="if(event.key==='Enter') addToCart()">
🛒
</div>
alt="description"Image text description for screen readersaria-label="text"Invisible label — icons, custom buttonsaria-labelledby="id"Reference visible element as labelaria-describedby="id"Reference element as extra descriptionaria-hidden="true"Hide from screen readersaria-live="polite"Announce dynamic changes when user pausestabindex="0"Add element to tab orderlabel for="id"Connect label to input — click target + screen reader:focus-visibleShow outline only on keyboard focusTools for testing accessibility:
Levels A, AA, AAA — legal compliance guide
Learn →
📢 ARIA Live Regions
Dynamic content announcements done right
Learn →
⌨️ Keyboard Navigation
Focus management, tab order, focus trapping
Learn →
🎨 Color Contrast
4.5:1 ratio, tools, dark mode considerations
Learn →
Accessibility is not backwards — it's forwards! Accessible website = better SEO, better UX for everyone, legal compliance. Not an "extra feature" — it's a "basic requirement".
Build an accessible biryani menu card — proper semantics, ARIA attributes, keyboard navigation, color contrast. Test with Chrome DevTools → Accessibility panel.
Open VS Code. Create accessible-menu.html.
Use the starter code below and add accessibility features:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Accessible Biryani Menu</title>
</head>
<body>
<main>
<h1>Paradise Biryani Menu</h1>
<!-- TODO: Add accessible menu items -->
</main>
</body>
</html>
Add these accessibility features:
Done — Key Points:
- ✅
alt= image description,alt=""= decorative, no alt = fail - ✅
aria-label= invisible label for icons/buttons - ✅
aria-labelledby= reference existing element as label - ✅
aria-hidden="true"= hide from screen readers - ✅
role= only for custom widgets, not semantic elements - ✅
aria-live="polite"= announce dynamic changes automatically - ✅
tabindex="0"= make non-interactive element keyboard accessible - ✅ Semantic HTML = free accessibility (nav, main, article, section)
- ✅ 4.5:1 contrast ratio minimum for normal text (WCAG AA)
Want to track your progress?
Log in to save your place and pick up where you left off.
Progress track karna chahte ho?
Login karo apni progress save karne ke liye aur jahan chhoda tha wahan se shuru karo.
Login