alt
textAnd much more!
Design with an inclusive mindset; create products everyone can use.
Clinical diagnoses:
Less severe:
Make accessibility considerations for all disabilities to provide an inclusive user experience.
Interface components must be presentable to users in ways they can comprehend.
label
s for controls and interface componentsUser interface components and navigation must be operable or usable.
Information and the operation of user interface must be understandable or easily comprehensible.
Content must be created in a way which can be interpreted reliably by a wide variety of user agents.
If any of these principles are not met, users with disabilities will not be able to use the web.
If you can't see the cursor on the page, you've got an accessibility issue
"Any keyboard operable user interface has a mode of operation where the keyboard focus indicator is visible."
*:focus {
outline: solid 3px red;
}
"If a Web page can be navigated sequentially and the navigation sequences affect meaning or operation, focusable components receive focus in an order that preserves meaning and operability."
Ensure the visual order of content matches the HTML order.
The tabindex
attribute
tabindex="-1"
tabindex="0"
tabindex="1"
or higherRefrain from adding tabindex="0"
everywhere!
demo-site/css/styles.css
file.Semantic HTML is the foundation of an accessible experience.
What is this thing and what does it do?
Semantics include…
"Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text."
Using semantic HTML is setting up your users for success.
The piece of content which gets announced is the currently focused item.
Screen reader | Start up | Shut down |
---|---|---|
VoiceOver |
|
|
NVDA |
|
|
Screen reader | Keys |
---|---|
VoiceOver | Ctrl + Opt then Left arrow or Right arrow |
NVDA | Up arrow or Down arrow |
Operating system | Browser | Screen reader |
---|---|---|
Windows | Internet Explorer | JAWS |
Windows | Firefox | NVDA |
Windows | Firefox | JAWS |
macOS | Safari | VoiceOver |
iOS | Safari | VoiceOver |
Android | Chrome | TalkBack |
title
The page title
is the first bit of information that is announced by a screen reader.
title
text
<title>outdoorsy</title>
<title>Contact | outdoorsy</title>
<title>Choose the Right Gear | outdoorsy</title>
<title>Error | Contact | outdoorsy</title>
<title>Payment information (Step 3 of 4) | Shop | outdoorsy</title>
"Web pages have titles that describe topic or purpose."
title
.title
content.People who depend on assistive technology often navigate by headings first.
<h1>Primary heading</h1>
<!-- … -->
<h2>Sub-section</h2>
<!-- … -->
<h3>Sub-sub-section</h3>
<!-- … -->
<h2>Sub-section</h2>
<!-- … -->
Landmark | HTML role |
Purpose |
---|---|---|
Header | banner |
Typically the first landmark element in the DOM, containing the main logo, primary navigation, and sometimes a search form. |
Footer | contentinfo |
Typically the last element in the DOM, containing links and copyright information. |
Aside | complimentary |
Contains content relative to the article or the site in general. |
Nav | navigation |
Used to denote navigation areas. |
Main | main |
The main content area of the page, typically found as a sibling to the header and footer . |
Section | — | A generic element used for sectioning off content such as portions of a page or article—not to be confused with the div which as no semantic meaning. |
"Headings and labels describe topic or purpose."
header
, main
, footer
, aside
, etc.Benefits of alt
text include SEO, and sighted users when the image fails to load.
However, screen reader users benefit most; allows participation in consuming non-text content.
alt
attributesrc
attribute value is announced by screen readersalt
value should be an exact matchalt
attribute value should be left emptyalt
text"A pair of low-top shoes are placed on top of a dark-brown table in front of a white brick wall. The shoes are mostly dark blue with a white midsole, brown laces, a black back tab, and white lining."
"Dark blue, low-top shoes with white midsole, brown lace, black back tab, and white lining."
"All non-text content that is presented to the user has a text alternative that serves the equivalent purpose."
demo-site/blog-post.html
.alt
text describing the image.alt
text.Element | Is announced as | Is activated by | Results in | Shifts focus? |
---|---|---|---|---|
a | "link" | Enter | Loading a new page, downloading a file, or jumping to a section on the same page. | Yes |
button | "button" | Enter or Space | Submitting a form or executing an on-screen action (eg., sorting table columns.) | No |
a:hover {
color: FireBrick;
}
a:hover, a:focus {
color: FireBrick;
}
a:active {
color: Black;
}
href
attributehref
Don't do this:
<a onclick="doSomething()">Do something</a>
Do this instead:
<a href="#doSomething" onclick="doSomething()">Do something</a>
href
valuehref
value"The purpose of each link can be determined from the link text alone or from the link text together with its programmatically determined link context."
<a href="#main" class="visuallyhidden focusable">Skip to content</a>
a
element with href
href
with the id
of the container.visuallyhidden
class.focusable
class
<a href="#main" class="visuallyhidden focusable">Skip to content</a>
<!-- … -->
<main id="main" tabindex="-1">
<!-- … -->
</main>
"A mechanism is available to bypass blocks of content that are repeated on multiple Web pages."
demo-site/index.html
.Object | Ratio |
---|---|
Text and images of text | 4.5:1 |
Large text (greater than 18pt ) |
3.0:1 |
Non-text (borders, icons) | 3.0:1 |
"The visual presentation of text and images of text has a contrast ratio of at least 4.5:1."
input
by screen readersGive the Placeholder demo a try.
label
associated with its input
Give the floating label demo a try.
label
is consistent, predictableinput
purposeTry out the always-visible label demo form.
"Labels or instructions are provided when content requires user input."
<label for="fname">First name</label>
<input type="text"
id="fname"
name="fname">
<span id="error-fname" class="error">First name is required</span>
aria-describedby
<label for="fname">First name</label>
<input type="text"
id="fname"
name="fname"
aria-invalid="true"
aria-describedby="error-fname">
<span id="error-fname" class="error">First name is required</span>
"If an input error is automatically detected, the item that is in error is identified and the error is described to the user in text."
demo-site/blog-post.html
and submit the Comment form.demo-site/js/form-validation.js
.input
with its related error message."Instructions provided for understanding and operating content do not rely solely on sensory characteristics of components such as shape, size, visual location, orientation, or sound."
<meta name="viewport" content="width=device-width, initial-scale=1">
"Content can be presented without loss of information or functionality, and without requiring scrolling in two dimensions."
"The size of the target for pointer inputs is at least 44 by 44 CSS pixels."
<a href="article/how-to-make-pasta-sauce.html">
Read more
</a>
<a href="article/how-to-make-pasta-sauce.html">
Read more
<span class="visuallyhidden">about How to Make Pasta Sauce</span>
</a>
aria-label
approach
<a href="article/how-to-make-pasta-sauce.html"
aria-label="Read more about How to Make Pasta Sauce">
Read more
</a>
"The purpose of each link can be determined from the link text alone or from the link text together with its programmatically determined link context, except where the purpose of the link would be ambiguous to users in general."
button
s
<button>Remove</button>
<button
aria-label="Remove {item title}">
Remove
</button>
<i class="icon icon-star star-4"></i>
<span class="icon icon-star star-4">
<span class="visuallyhidden">4 out of 5</span>
</span>
display: none
(difficult to animate)visibility: hidden
(easier to animate)hidden
attribute
<span hidden>Hidden content</span>
If visually hidden, hide from keyboard and assisitve technology, too.
"If a Web page can be navigated sequentially and the navigation sequences affect meaning or operation, focusable components receive focus in an order that preserves meaning and operability."
prefers-reduced-motion
media query
a {
color: Crimson;
transition: color .25s;
}
a:focus, a:hover {
color: FireBrick;
}
@media (prefers-reduced-motion) {
a {
transition: none;
}
}
"Motion animation triggered by interaction can be disabled, unless the animation is essential to the functionality or the information being conveyed."
demo-site/blog-post.html
and
demo-site/css/styles.css
.prefers-reduced-motion
media query to disable the fade-in animations.Attribute | Purpose | Example |
---|---|---|
role |
Used to add or alter the base semantic meaning of an element. |
|
aria-label |
Adds an accessible name to an element. |
|
aria-disabled |
Announces the element as in a "disabled" state. |
|
label
elementinput
element
<label for="apple-checkbox">
<input type="checkbox"
id="apple-checkbox"
name="apple">
Apple
</label>
<div class="checkbox__wrapper">
<div class="checkbox__checkbox"
role="checkbox"
tabindex="0"
aria-checked="false"
aria-labelledby="apple-checkbox"></div>
<div class="checkbox__label"
id="apple-checkbox">Apple</div>
</div>
Refer to the WAI-ARIA 1.1 spec document for more information.
Key | Expected interaction |
---|---|
Tab |
|
Shift + Tab |
|
Escape | Dismisses the modal window. |
Element | Attribute | Usage |
---|---|---|
Launcher button |
aria-haspopup="modal" |
Informs the user of a modal context upon interaction |
Modal container div |
role="dialog" |
Identifies the current container and context as a modal window |
Modal container div |
aria-labelledby="IDREF" |
Helps to describe the purpose of the modal window by referencing the h2 heading element — if no heading is available, use aria-label instead |
Modal container div |
aria-modal="true" |
Informs assistive technologies that the content underneath the current dialog are not available for interaction |
inert
attributeinert
<header inert>
<!-- … -->
</header>
<main inert>
<!-- … -->
</main>
<footer inert>
<!-- … -->
</footer>
<div class="modal" …>
<!-- … -->
</div>
demo-site/popup.html
demo-site/js/modal-window.js
"Don't think of accessibility as a chore that's too difficult to implement, but rather a coding challenge."– @vavroom
Find me @svinkle — DMs are always open! 🚀