Semantics and accessibility
Accessibility essentials
Goal: Apply the most important accessibility rules in HTML · 10 min
Accessible pages work for everyone — people using screen readers, keyboards, zoom, or slow connections. In the EU, many public and commercial websites are legally required to be accessible (WCAG is the technical reference).
Checklist for HTML:
- Use the right element: a
<button>for actions, an<a>for navigation. A clickable<div>is not reachable by keyboard. - Text alternatives for images (alt).
- Logical heading order and landmarks.
- Labels for every form field.
- Language set with lang (and on passages in another language).
- Don't rely on colour alone ("fields in red are required").
- Test: navigate your page using only the Tab and Enter keys.
ARIA attributes exist, but the first rule of ARIA is: prefer native HTML elements.
Worked example: Button vs. clickable div
- The div is not focusable and not announced as a button.
- The button works with Tab, Enter and Space automatically.
- Same look is possible with CSS.
<div class="btn" onclick="save()">Save</div>
<button type="button" onclick="save()">Save</button>