Lesson 24 / Accessibility
Web Accessibility
Run a practical final accessibility pass with semantic HTML, keyboard testing, contrast checks, form labels, useful alt text, and WCAG 2.2 AA guidance.
Course Role
Core
Part of the main course path. Prioritize this before moving to optional polish or deeper references.
Teacher Notes / In-Class Use
Demo Live
- Use the accessibility lab to toggle one issue at a time and connect each failure to a user impact.
- Run a keyboard-only pass before talking about automated audits.
Try In Class
- Have students navigate their project without a mouse and write down the first place they get stuck.
- Ask students to check body text, link, and button contrast before final visual polish.
Submit Or Check
- Projects should have semantic structure, visible focus, useful alt text, labels, and sufficient contrast.
- Automated tools can support the review, but students should also perform manual keyboard testing.
Watch For
- Students treating Lighthouse as the whole accessibility process.
- Interfaces that rely on color alone to communicate state.
Learning Goals
- Explain accessibility using the POUR principles
- Use native HTML before reaching for ARIA
- Audit a project for headings, landmarks, alt text, labels, contrast, focus, and keyboard access
- Use automated tools as support, not as the whole accessibility process
Interactive Demo
How to use this demo.
Use the demo as a small lab. Change one thing, observe the result, then connect it back to your own project.
What To Try
- Toggle each accessibility issue and watch the preview, checklist, and code change.
- Use the preview like a mini audit before checking your own project.
What Changes
- The same UI becomes more or less accessible based on markup, contrast, focus, and control choices.
- The checklist turns abstract accessibility language into concrete checks.
What To Notice
- Accessibility problems often come from small implementation choices.
- Manual testing catches issues that automated tools may miss.
Apply It
- Run the same checks against your own project: alt text, contrast, focus, and semantic controls.
Interactive Demo
Accessibility Check Lab
Toggle common accessibility issues and watch the checklist update. The goal is to practice noticing problems before they ship.
Student Project Feature
This paragraph has enough contrast to stay readable for more people.
- Alt text: Pass
- Contrast: Pass
- Focus style: Pass
- Semantic control: Pass
<img src="project.jpg" alt="Student project preview">
<button type="button">Save project</button> What to notice
- Accessibility issues often look small but change who can use the page.
- Native HTML solves many problems before ARIA is needed.
- Visible focus and contrast are part of the interface design.
Try this
- Turn off one checkbox and explain what broke.
- Use the Tab key to test focus visibility.
- Apply the checklist to a page from your own project.
This demo uses extra JavaScript for teaching. The code sample shows the pattern to practice. View full demo source.
Accessibility Is Part of Quality
Accessibility means more people can perceive, navigate, understand, and use your site. It helps people with disabilities, people using assistive technology, people on mobile devices, and anyone dealing with temporary limits like glare, injury, noise, or slow connections.
For your final project, treat accessibility as a quality check. A page is not finished until it works with a keyboard, has readable contrast, uses meaningful structure, and communicates clearly to assistive technology.
The POUR Principles
| Principle | Meaning | Student Project Check |
|---|---|---|
| Perceivable | Users can get the information through sight, sound, or assistive technology. | Images have useful alt text, text has enough contrast, and videos have captions or transcripts. |
| Operable | Users can navigate and interact with the interface. | Links, buttons, forms, menus, and carousels work with the keyboard and show visible focus. |
| Understandable | The content and interface are clear and predictable. | Headings, labels, instructions, errors, and link text make sense. |
| Robust | The site works across browsers, devices, and assistive technologies. | HTML is valid, controls use native elements, and ARIA is used carefully. |
WCAG 2.2 AA
WCAG stands for Web Content Accessibility Guidelines. It is the shared standard used to evaluate web accessibility.
For student projects, use WCAG 2.2 AA as the practical target. Level A covers basic barriers, level AA is the common professional goal, and level AAA is stricter but not always realistic for every page.
WCAG is not a replacement for empathy or testing. It gives you measurable checks, but you still need to use the page the way real users might use it.
Native HTML First
Start with the HTML element that already has the meaning and behavior you need. A real button can receive focus, respond to keyboard input, and communicate its role automatically. A clickable div cannot do those things unless you rebuild them manually.
Use ARIA only when native HTML cannot express the meaning. ARIA can improve custom interfaces, but incorrect ARIA can make a page more confusing.
| Need | Use This | Avoid This |
|---|---|---|
| Page navigation | nav with links | A plain div with unlabeled links |
| Clickable action | button type="button" | div onclick="..." |
| Form prompt | label for="email" linked to input id="email" | Placeholder text as the only label |
| Main page content | main | Multiple unlabeled content wrappers |
| Standalone article or card content | article when the content can stand alone | Generic markup with no structure |
Final Project Accessibility Pass
Use this order when reviewing a project. It moves from structure to interaction to automated checks, which helps you catch the problems students most often miss.
| Step | What To Check | How To Test |
|---|---|---|
| Structure | One h1, logical heading order, useful title, and landmark elements like header, nav, main, and footer. | Scan the HTML and use the browser accessibility tree or outline tools. |
| Content | Images, icons, link text, page language, captions, and readable copy. | Ask whether the page still makes sense without seeing the visual layout. |
| Keyboard | Every interactive element is reachable, usable, and has visible focus. | Use Tab, Shift + Tab, Enter, Space, and arrow keys where appropriate. |
| Forms | Each input has a label, instructions are clear, and errors explain how to fix the problem. | Click each label, submit invalid data, and check the error message. |
| Visual Design | Text contrast, button contrast, spacing, target size, and motion settings. | Use a contrast checker and test on small screens. |
| Automation | Run Lighthouse, axe, or another audit tool after manual testing. | Fix tool warnings, then retest manually. |
Headings and Landmarks
Headings create the page outline. Landmarks help users jump to major regions of the page. Do not choose heading levels based only on font size; choose them based on structure.
<header>
<nav aria-label="Main navigation">
<a href="/">Home</a>
<a href="/projects/">Projects</a>
</nav>
</header>
<main>
<h1>Restaurant Guide</h1>
<section aria-labelledby="featured-heading">
<h2 id="featured-heading">Featured Restaurants</h2>
<article>
<h3>Coastal Kitchen</h3>
<p>Seafood restaurant with outdoor seating.</p>
</article>
</section>
</main> Alt Text
alt text should communicate the purpose of the image in context. A product photo, project screenshot, chart, or important illustration usually needs descriptive alt text.
Use empty alt="" only for decorative images that add no new information.
| Image Type | Better Alt Text | Reason |
|---|---|---|
| Project screenshot | alt="Homepage mockup for a local restaurant website" | Names what the image shows. |
| Product image | alt="Black cotton hoodie with white logo" | Describes information a buyer may need. |
| Decorative divider | alt="" | Prevents assistive technology from announcing visual decoration. |
| Chart or diagram | Short alt plus nearby explanation | Complex information needs more than one short sentence. |
Links and Buttons
Links move users to another place. Buttons perform an action on the current page. Do not use vague link text like "click here" when the link can describe its destination.
<!-- Less helpful -->
<a href="/projects/responsive-landing-page/">Click here</a>
<div class="button">Open menu</div>
<!-- Better -->
<a href="/projects/responsive-landing-page/">View the responsive landing page project</a>
<button type="button">Open menu</button> Forms and Errors
Every form control needs a programmatic label. Helpful instructions and error messages should be connected to the input with aria-describedby when they provide extra context.
<label for="email">Email address</label>
<input
id="email"
name="email"
type="email"
autocomplete="email"
aria-describedby="email-help email-error"
aria-invalid="true"
>
<p id="email-help">Use the email address you check most often.</p>
<p id="email-error">Enter an email address that includes an @ symbol.</p> Focus Styles
Keyboard users need to see where focus is. Do not remove outlines unless you replace them with a visible focus style.
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
outline: 3px solid currentColor;
outline-offset: 3px;
} Contrast and Color
For normal body text, aim for at least 4.5:1 contrast. Large text can pass at 3:1, but body copy, navigation, buttons, and form text should be easy to read in real conditions.
Never rely on color alone to communicate meaning. Pair color with text, icons, labels, borders, or patterns.
| Problem | Why It Fails | Better Approach |
|---|---|---|
| Red text alone means error | Color-blind users may miss the meaning. | Add text like "Error" and explain the fix. |
| Pale gray body copy | Low contrast makes reading harder. | Darken the text or lighten the background. |
| Hover-only navigation state | Touch and keyboard users may not see it. | Include :focus-visible and active states. |
Motion and Media
Animation, video, and autoplay can create barriers. Avoid flashing content, avoid surprise motion, and respect prefers-reduced-motion when using animation.
If a video includes speech or important sound, provide captions or a transcript. If a carousel or animation autoplays, give users a way to pause it.
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms;
animation-iteration-count: 1;
scroll-behavior: auto;
transition-duration: 0.01ms;
}
} Automated Tools Are Support
Tools like Lighthouse and axe can catch missing labels, contrast issues, invalid ARIA, and other common problems. They cannot fully judge whether link text is meaningful, whether alt text is useful, or whether a keyboard workflow feels clear.
Run automated checks after a manual pass, then fix issues and test again. Passing an automated audit does not guarantee the page is accessible.
Use the Accessibility Check Lab
The interactive demo below models the same checks you should run on your project: text alternatives, contrast, visible focus, and semantic controls.
Toggle each issue, inspect the code, then find the matching pattern in your own project. The goal is to practice noticing problems before they ship.
Common Mistakes
| Mistake | Why It Hurts | Fix |
|---|---|---|
| Treating Lighthouse as the whole test | Automated tools miss context and real interaction problems. | Do keyboard and content checks first, then run tools. |
Using div or span for controls | Users may not be able to focus or activate them. | Use real button, a, input, and label elements. |
| Skipping visible focus styles | Keyboard users lose their place. | Add strong :focus-visible styles. |
| Writing vague links | Users cannot predict where the link goes. | Use descriptive link text. |
| Using ARIA to patch bad HTML | Incorrect ARIA can create confusing output. | Fix the native HTML first. |
Checkpoint
Before moving on, make sure these feel true.
- I can test a page using only the keyboard.
- I can check contrast, labels, alt text, and heading structure.
- I can explain why automated audits do not replace manual testing.
Project Connection
This lesson supports current class projects.
Practice
- Navigate your project using only
Tab,Shift + Tab,Enter, andSpace. - Check that your page has one
h1and a logical heading order. - Review every image and decide whether it needs useful
alttext or emptyalt="". - Check body text, links, buttons, and form controls with a contrast checker.
- Confirm every form input has a visible
labeland helpful instructions or errors when needed. - Run Lighthouse or axe and fix at least one issue it reports.
- Write down one accessibility improvement you made before submitting your project.