Table of Contents
- Front-end Accessibility Checklist
- A11y Dev Tools
- In-browser A11y Check Tools
- Screen Reader + Browser Testing Setup
Front-end Accessibility Checklist
In every pull request, developers are required to review the HTML code based on the following guidelines.
Images
- All
<img>
s have thealt
attribute. Pass an empty value if it is a decoration:alt=""
. - All informative
<svg>
s have a<title>
that renders the accessible name androle="img"
, and all decorative<svg>
s have thearia-hidden
attribute.
// Informative SVG
<svgrole="img"><title>Accessible label</title>...</svg>
// Decorative SVG
<svgaria-hidden="true">...</svg>
Links and Buttons
- Let links be links. All
<a>
s have thehref
attribute defined, it cannot be empty. Links must navigate somewhere, either to a different page or another section of the same page. Links should not perform functions. Links trigger onenter
. - Let buttons be buttons. All
<button>
s havetype
attribute defined, it can besubmit
,reset
, orbutton
depending on the scenario. Buttons must perform functions, it can never be used for navigation. Buttons trigger onenter
orspace
. -
<a>
and<button>
elements do not havetabindex
androle
attributes. These are already semantic interactive elements. -
<input>
s are not used as buttons. - Links and buttons have unique accessible labels (eg. multiple links or buttons cannot be exactly labelled as "read more").
Button Link Combo
⚠️ I hope you never have to do this but if you do...
- If an
<a>
performs a function in addition to navigating somewhere , it must include therole="button"
attribute, and additional work must be done to make such custom button trigger onspace
andenter
. This is common for a control that does ajax functions with JS on but links to some other page with JS off.
Title Attribute
- Avoid using
title
attribute on any element unless it's an<iframe>
. ( source)
Skip Link
- The page has a skip link that would navigate the user to the main content of the page. This is usually visually hidden until the user focuses on it using the keyboard. The
href
must be set to the same id as the main content container. For example:<a href="#main-content">
. - The skip link is the immediate child of the
<body>
and first-of-type. - Main content container has an id that corresponds with the skip link.
<body>
<a href="#main-content">Skip to content</a>
...
<main id="main-content">...</main>
...
</body>
Landmarks
- The page has only 1
<header>
that is a child of<body>
and not a child of any landmarks. Such header is the equivalent ofrole="banner"
. - The page has only 1
<footer>
that is a child of<body>
and not a child of any landmarks. Such footer is the equivalent ofrole="contentinfo"
. - The page has only 1
<main>
. - The page has an
<aside>
as a sibling of<main>
if the content has complimentary info such as a sidebar. - The page has a
<nav>
for each group of navigation. If multiple<nav>
s exist, usearia-label
to name each one. - The page has
<section>
s if the content is divided into sections. Each<section>
must have an immediate heading as the first child (h2 to h6) oraria-label
that describes the section. - Landmarks do not need
role
attributes. Do not do this<main role="main">
or this<footer role="contentinfo">
.
Headings
- The page has only 1
<h1>
. - The headings do not skip levels. For example, an
<h3>
cannot follow immediately after an<h1>
. - The headings have unique accessible labels (eg. multiple headings cannot be exactly labelled as "Get Started").
Other Checks
- Keyboard focus follows the visual layout of the content. Left-to-right, top-to-bottom for LTR languages. Right-to-left, top-to-bottom for RTL languages.
- Text have at least a 4.5:1 contrast ratio with its background. Interactive and meaningful graphical elements must have a minimum 3:1 contrast ratio.
- Text is able to enlarge to 400% without loss of information.
- Web content can reflow, without horizontal scrolling, at a screen width of 320px (equivalent to a starting viewport width of 1280px wide at 400% zoom).
- Click or touch areas should be a minimum of 44px x 44px unless the target is in a sentence or block of text.
- Interactive controls have an enclosing indicator when gaining keyboard focus.
- Videos have captions.
- Motion is reduced or removed when the user device has "reduce motion" setting turned on.
A11y Dev Tools
In-browser A11y Check Tools
- HTML Validator
- Sa11y—Accessibility Check Bookmarklet
- WAVE—Accessibility Check Chrome Extension
- Assistiv Labs—VMs with Screen Readers
- Who Can Use—Color Contrast Checker
Screen Reader and Browser Testing Setup
The following should be used as the standard setup for testing accessibility.
Mac and iOS
- Safari + VoiceOver
Windows
- Chrome/Firefox/Edge + JAWS
- Chrome/Firefox/Edge + NVDA
- Edge + Narrator
Android
- Chrome + Talkback