HTMLadvanced 9 min
Make pages usable with a keyboard and a screen reader: alt text, labels, headings, landmarks and ARIA.
The core habits that make a page usable by people with different abilities and tools.
Around one in six people live with a disability. Many use a keyboard instead of a mouse, a screen reader, or high zoom. Accessible pages are also easier for everyone, and often required by law for public services.
Accessibility (often written a11y) means designing so that people can perceive, operate and understand the page. Most of it comes from using HTML properly:
alt text. Decorative images use alt="".<label>.h1 to h6 in order and semantic tags such as main and nav so users can jump around.<button> and <a> elements do this for free.ARIA attributes (such as aria-label) add meaning where HTML alone is not enough. The first rule of ARIA: if a native HTML element does the job, use it instead.
<nav aria-label="Main"> names the navigation landmark.aria-label="Close dialog" tells a screen reader what it does.<label>.alt describes the information in the chart, not just "chart".Press Tab repeatedly to walk through the page using only the keyboard. Then add an alt to a new image.
<div onclick> cannot be reached by keyboard. Use <button>.outline: none and nothing in its place.Next: audio and video.
<a href="#content">Skip to main content</a>
<nav aria-label="Main">
<a href="#">Home</a>
<a href="#">Courses</a>
</nav>
<main id="content">
<h1>Welcome</h1>
<button aria-label="Close dialog">X</button>
<label for="q">Search</label>
<input id="q" type="search">
<img src="https://placehold.co/120x60/png?text=Chart" alt="Bar chart: sales doubled in 2024" width="120" height="60">
</main>