CHAPTER 50 · HTML
Accessibility basics: make meaning and actions available to more people
Bring together headings, labels, text alternatives and keyboard use. Build useful native HTML and review real behaviour instead of relying on appearance alone.
Download example files (ZIP)Start with people using the page
Use native elements for their actual jobs
Keyboard use: follow a visible route
Provide a skip route past repeated navigation
Give images and graphics a text purpose
Label fields and explain rules before errors
Use ARIA to support meaning, not invent behaviour
Review content, presentation and interaction together
Follow the idea
- 1Meaningful elements and headings
- 2Names and instructions
- 3Keyboard access and visible focus
- 4Text alternatives and actual testing
A tidy appearance or a single automated check is not a complete review.
Complete program: accessible-session.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>A Readable Session Page</title>
<style>
body {
color: #202c3a;
background: #fff;
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 1rem;
}
a {
color: #174a94;
}
a:focus-visible {
outline: 3px solid #174a94;
outline-offset: 3px;
}
img {
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<h1>A practice session everyone can follow</h1>
<p><a href="#main-content">Skip to main content</a></p>
<nav aria-label="Page sections">
<a href="#about">About the session</a> | <a href="#session">Session details</a>
</nav>
<main id="main-content" tabindex="-1">
<section id="about">
<h2>About the session</h2>
<p>Bring one saved HTML page and explain it to a partner.</p>
</section>
<section id="session">
<h2>Session details</h2>
<p>This fictional session meets in Room B-204. Keep your own notebook with you.</p>
<img
src="images/study-desk.svg"
alt="An open notebook beside a laptop on a study desk"
width="360"
height="220"
/>
</section>
</main>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.
Complete program: accessible-question.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>A Clearly Labelled Practice Form</title>
<style>
body {
color: #202c3a;
background: #fff;
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 1rem;
}
input,
textarea {
max-width: 100%;
box-sizing: border-box;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
outline: 3px solid #174a94;
outline-offset: 3px;
}
</style>
</head>
<body>
<h1>Ask a fictional practice question</h1>
<main>
<p>
This is an HTML exercise, not a message service. Keep form-result.html from Chapter 31
beside this file.
</p>
<form action="form-result.html" method="get">
<fieldset>
<legend>Practice question</legend>
<p><label for="practice-alias">Practice alias (required)</label></p>
<p id="alias-help">
Use an invented name. Do not enter private information in this URL-based exercise.
</p>
<p>
<input
type="text"
id="practice-alias"
name="alias"
required
maxlength="30"
aria-describedby="alias-help"
/>
</p>
<p>
<label for="practice-question">Your question (required, up to 120 characters)</label>
</p>
<p>
<textarea
id="practice-question"
name="question"
required
maxlength="120"
rows="3"
cols="28"
></textarea>
</p>
</fieldset>
<button type="submit">Inspect practice values</button>
</form>
</main>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here. Form submission is disabled in this preview. Save the example and its result page locally to test submission. Use fictional practice values.
Problem and solution
Common mistakes and useful tips
Do not build ordinary buttons from clickable divs. Do not remove focus outlines for appearance. Do not make every paragraph a Tab stop. Placeholder is not a substitute for a label. Do not hide interactive controls from assistive tools. Do not call one automated test a complete accessibility review.
Practice questions
Why use a native button for an action? Which key normally moves to the next interactive control? What does the skip link target? How is decorative alt="" different from omitted alt? Does ARIA automatically add keyboard behaviour? Save both examples. Test the skip link, form labels, Tab route and required checks using invented values. Record one result for each.
Check your practice answers
It supplies appropriate native semantics and keyboard behaviour rather than relying on a decorative div. Tab; Shift+Tab moves backward. Main-content, the id of the main region. An empty alternative intentionally marks a decorative image. Omitted alt does not express that intention. No. It describes meaning or state, not the missing interaction logic. The skip route should focus main, labels should target their controls, native controls should be reachable, and empty required fields should block ordinary submission. State only the behaviours you actually observed.
Interview questions
What is an accessible name?
Why is semantic HTML not the whole task?
How do label and aria-describedby differ?
Can an automated checker prove full accessibility?
Quick revision
Choose native elements and clear names. Keep a logical visible keyboard route. Provide meaningful text alternatives and instructions. Combine automated checks with real use.