ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

Web Accessibility (a11y) Tutorial• 6 min read

Semantic HTML: The Bedrock of Accessibility

Why <button> beats <div onclick> and landmark elements (main, nav, header)

The single most effective action you can take for accessibility is writing clean semantic HTML elements instead of unsemantic <div> containers.

Native Elements vs Unsemantic Divs

Native <button>: Automatically provides keyboard focusability (tabindex="0"), Enter/Space key event triggering, and screen reader announcements without a single line of JavaScript.

Div Button (<div onclick="...">): Invisible to keyboard navigation, ignored by screen readers, and requires manual ARIA roles and keydown handlers.

Landmark elements (<header>, <nav>, <main>, <aside>, <footer>): Allow screen reader users to jump directly across major page sections using shortcut keys.

Semantic HTML vs Unsemantic Soup
<!-- INACCESSIBLE: Invisible to screen readers and keyboard users -->
<div class="btn" onclick="submitForm()">Submit</div>

<!-- FULLY ACCESSIBLE: Native focus, keyboard support, screen reader role -->
<button type="submit" class="btn">Submit</button>
Native semantic elements provide accessibility for free.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

Why is using a native `<button>` element vastly superior to using a `<div onclick="...">` for interactive controls?