Accessibility The Crafting of a Friendlier and More Considerate Web
Lauren Woodrick
lwoodrick|LoremIpsam
Why It Matters
What We'll Cover
The Standards
Accessibility Considerations Throughout A Project
Design: Text and Graphical Elements
Development: Components and Attributes
Testing: Tools and Resources
The Standards
WCAG 2.0
WCAG 2.0 is the second iteration of the standards written by the W3C to
outline elements of structure that make websites accessible.
What are the standards?
The overarching goal is to make sure that your pages are
Perceivable
Operable
Understandable
Robust
The Design Phase
Design: Typeface
Select typefaces that are readable for a wide variety of users, including those with low-vision and dyslexia.
Longer ascenders and descenders to make different letterforms more distinct from each other.
No ornamentation that obscures the letterforms.
Design: Typeface
Select typefaces that are readable for a wide variety of users, including those with low-vision and dyslexia.
Letterforms that are distinct from others that are formed in a similar way.
Letterforms with generous counters also have an edge in readability for low-vision users.
Design: Typeface
Additionally, a study performed in 2013 using system fonts and a font designed specifically for dyslexics found a reading preference for sans-serif typefaces (favoring Humanist-style), though reading speed was pretty even across your usual suspects of non-florid fonts. (Verdana, Helvetica, Arial, Courier, Times New Roman, etc.) Also, don't set large sweeps of copy in italic unless you're a monster and you want people to be unhappy.
Design: Typeface
If you'd like to do some guerilla simulation of low-vision on sweeps of text, you can try applying a style of filter: blur(3px); to the relevant text and then make determinations on font and style. Adjust the blur to taste.
The next slide has an example of the effect used on Google Fonts.
Design: Type Size
Sometimes, in spite of your best efforts, users will have to zoom in to be able to read your page comfortably.
Design: Type Size
Embrace the relative! Set font-size, padding, and margin to relative
units (rem, em, ch) to make it possible to zoom gracefully!
(View WCAG SC 1.4.4)
Design: Text
Keep fields of text text-align: left;
For paragraphs, keep line-height: 1.5;
Bonus: Paragraphs between 45–75 characters long are most comfortable for reading, so consider sizing your text blocks with the respective rem units. (View WCAG SC 1.4.8)
Design: Links
When possible, make it explicit what kind of content a link links to reduce cognitive load on the user. (View WCAG SC 2.4.9)
If for some reason, it can't be done, that's fine — so long as all users are left with a sense of mystery, this criteria still counts as passed.
Design: Links
At the very least, context should hint at where a link might be taking the user. (View WCAG SC 2.4.4)
To make this easier for assistive technologies, use the aria-label attribute to provide more information about where a link might take you or point at information that does describe a link using aria-labelledby
Design: Links
Text links are also best displayed underlined to be distiguishable from normal copy for colorblind users. (View WCAG 1.4.1)
Design: Links
As a bonus, here's a spin on the text-underline that also keeps decenders in the link text from becoming obscured:
As a baseline, be sure that the contrast ratio between the
background and text is at least 4.5 for all text and at least 3 for text
that's above 14pt and bold or above 18pt in size. This should guarantee readability for users with 20/40 vision (View WCAG SC 1.4.3)
Design: Color
To take it to the next level and be a hero to people with 20/80 vision, you can aim for a contrast ratio of 7 for your copy. (View WCAG SC 1.4.6)
Design: Color
Any information imparted by charts or graphs by the use of color should be made available in another way for folks with varying types of colorblindness. (View WCAG 1.4.1)
Design: Color
Here's a nice example in the wild for how Trello accommodates for colorblindness in its card labels.
Design: Color
Here are some nice tools to keep yourself honest.
Contrast-Ratio: A handy tool for spot-testing text and background contrast.
Color Oracle: A desktop plugin to simulate different types of colorblindness.
Design: Images
If there's alt text, (or <title> text for svgs) it will be read by screen readers.
If there's no alt text, screen readers will have no choice but to read the entirety of the <img src>.
Selectively load images based on the device being used using <picture>. (View Documentation)
Use SVG where possible for small file sizes.
Design: Images of Text
Logos are permissible when augmented with alt text, but any other manifestations of image-based text should be strictly decorative. (View WGAC SC 1.4.5)(View WGAC SC 1.4.9)
Be sure not to let any animations on your page flash more than three times per second — any faster is a risk for users prone to seizures. (View WCAG SC 2.3.2)
Use critical path CSS to prevent any background-images from causing load havoc.
FOUT (Flash of Unstyled Text) is superior to FOIT (Flash of Invisible Text)!
Development: Markup Order
As your page reads from the top down, so should your markup. This ensures assistive technologies and keyboard users will be able to digest and navigate information in the same sequence as other users. (View WCAG SC 2.4.3)
Development: Keeping It Semantic
When possible, use semantically-appropriate HTML tags for your content.
Development: Headers
Conveniently and very self-evidently, <header> tags should be used for headers.
Attach the attribute of role="banner" to your primary header.
Development: Navigation
You don't have to reinvent the wheel — adhering to layout conventions common on the web allow you to piggyback on their existing familiarity.
Keep page navigation and controls in the same location as often as possible! This helps users familiarize themselves with the layout and anticipate where they'll find the content they seek in the future. (View WCAG SC 3.2.3)
Development: Navigation
Just like the with <header>, there are handy <nav> tags to serve this purpose.
Attach the attribute of role="navigation" for navigational, but non-<nav> elements.
Use the WAI-ARIA attribute of aria-label or reference a navigational area's header with aria-labelledby to make its purpose clear
Development: Navigation
Making search functionality available also provides a nice bump to accessibility and provides opportunities to navigate across pages in the normal flow outside of the main navigational fixtures. (View WCAG SC 2.4.5)
Development: Navigation
When possible, keep it clear where the user is currently located, whether by providing a visual indicator within the site's navigation or providing breadcrumbs marking their path. (View WCAG SC 2.4.8)
Development: Navigation
For touch-based devices, aim for a minimum of 44px × 44px (if you believe Apple) or 48px × 48px (if you believe Google).
This should allow most folks to select an element on the screen without obscuring the content and possibly misselecting.
Development: Navigation
When utilizing dropdown or slide-out navigation, use role and aria attributes to prevent a complete readout of submenus and keep from "losing" focus. (View WCAG SC 2.4.1)
Speaking of :focus, leave that blue halo serving as a focus indicator alone unless you're replacing it with something else! (View WCAG SC 2.4.7)
Development: Navigation
To add a non-link or form element to the tab flow, add the attribute tabindex="0" to the element.
If you want to take an tabbable item and prevent it from appearing in the order by default to apply other behavior, use the tabindex="-1" attribute.
It's also not enough to make sure that everything's focusable for keyboards, flow also needs to be considered. (An Example)
Development: Navigation
To prevent a full read-out of navigation or forcing a keyboard user to tab through it again on a page load, provide a "Skip to Content Link" in your header before the <nav> that's only visible to the user on :focus.
Stay vigilant against keyboard traps whenever bucking default element behavior and prescribing something new with JavaScript!
Development: Main
Use the <main> tags for your primary content area, as well as the role="main" landmark as an attribute.
Development: Headings
When content is broken into sections, be sure to make headings as descriptive of the content as possible and use them in sequence (i.e. h1..h6) to make content more digestable and navigable. (View WCAG SC 2.4.10)
Development: Forms
When constructing forms, be sure that all of your form fields have labels that they're associated to. (View WCAG SC 2.4.6)
Development: Forms
Don't depend on placeholder text as a label replacement. It can provide context as to what belongs in a form field, but once a user begins to type in it, that context is lost and unrecoverable for purposes of form review.
Development: Communicating State
Mark elements that are hidden within the interface with the aria-hidden="true" attribute and toggle its state to false with JavaScript when it changes.
If elements contain a submenu, aria-haspopup="true" will communicate this to assistive technology. Likewise, aria-expanded="true" will indicate whether or not an expanding element is open.
Development: State & Properties
For users to keep the best grasp on context, make redirects, where they occur, as instantaneous as possible.
Only allow the page to refresh upon being triggered by the user to keep page transitions expected (View WCAG SC 3.2.5)
In cases where user sessions time out, be kind and take the user back to where they left off to prevent disorientation.
Development: Not-So-Secret Text
For elements that act as visual dividers, the role="presentation" can be used to get screenreaders to ignore it.
Development: Not-So-Secret Text
For non-sighted users who need additional context provided for other users via images or CSS, provide content that will be picked up by screen readers but "invisible" to other users with this utility class: