Doing Your Part Coding Accessible WordPress Websites

Mark Root-Wiley is…

- MRW Web Design
- WordPress Websites for Nonprofits & Mission-Driven Organizations
- Planning, Design, Development, Training
- WordPress Plugin and Theme Author
- @MRWweb on Twitter
…not an Accessibility Expert.

- Just a guy who makes websites
- If I can do it, you can do it!
Here we go!
- What accessibility is & why it's important
- Real tips & tricks
- WordPress-specific accessibility
All with lots of links for future reference.
Slides at http://MRWweb.com/wc15/a11y-code/
What is Accessibility?
Web accessibility is a subset of [user experience] focused on making your websites usable by the widest range of people possible, including those who have disabilities.
— "MYTH: Accessibility is 'blind people'," a11yproject.com
See also: "Reframing Accessibility for the Web"
"Gretel": Keyboard Navigator
Gretel writes code for a living and navigates with a keyboard because of RSI.

"Hansel": Screen Reader User
Hansel is a writer and has a visual impairment so listens to computers with a "screen reader" software.

"Jack," "Sawyer," & "Kate"
Red-green color blind. Uses voice commands. Can't find glasses.

They're all lost without web accessibility!
And so is everyone else…

"Universal Design"
We all benefit from accessible spaces and interfaces.
- People with limited mobility & people with a bad touchpad
- People with low vision & people with glare on their screens
- People who use browser zoom for all reasons.
- EVERYONE! There is no "them."
A good website IS an accessible website.
Why It Matters: WebAIM's Hiearchy of Motivating Accessibility

From least to most effective: Guilt, Punish, Require, Reward, Enlighten, Inspire!
Adapted from: "WebAIM's Hierarchy for Motivating Accessibility Change"Benefits of Accessibility

- Punish: Avoid Lawsuits (Target, Harvard/M.I.T, Scribd, Seattle Schools)
- Reward: Return on Investment (ROI)
- Reward: Side Benefits: Better SEO, Progressive Enhancement
- Inspire: Pride in your work!
- Inspire: A web for all!
Do Your Part!
- Designers: Contrast, font size,
:focus
states - Developers!
- Editors: Descriptive link text, alternative attributes, video/audio transcripts

Accessibility First!
Both thinking and coding. Just like "mobile first."
Fewer mistakes. Better foundation.

Accessibility for Developers
Common issues and techniques:
- Text alternatives (images, icons, etc.)
- Keyboard navigation (
:focus
, skip links) - Clear labeling (form
label
s, buttons, unique links) - Source order, heading structure, & ARIA landmarks (i.e.
role="_____"
)
Code Examples

- So much to say and so little time!
- Focus on quick wins
- Multiple applications of one basic technique
Screen Reader in Action!
Screen Reader Text
Required for all new WordPress.org themes!
Bad Code
.screen-reader-text {
display: none;
}
.screen-reader-text {
visibility: hidden;
}
Good Code
.screen-reader-text {
clip: rect(1px, 1px, 1px, 1px);
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
}
Twitter Icon
Result
Bad Code
<a href="dashicons dashicons-twitter" href="http://twitter.com/MRWweb"></a>
Good Code
<a class="dashicons-before dashicons-twitter" href="http://twitter.com/MRWweb">
<span class="screen-reader-text">@MRWweb on Twitter</span>
</span>
"Read More" Links
Result
Bad Code
<a href="#">Read more…</a>
Good Code
<a href="#">Read more<span class="screen-reader-text"> of "{Put Article Title Here}"</span>…</a>
"Read More" Links in WordPress
Straight outta the Theme Handbook!
<?php
the_content(
sprintf(
__( 'Continue reading%s', 'textdomain' ),
'<span class="screen-reader-text"> ' . get_the_title() . '</span>'
)
); ?>
Screen Reader Text for Forms
Search Form Result
Bad Code
<form role="search" method="get" id="searchform" class="searchform">
<input type="text" value="" name="s" id="s" />
<button type="submit" id="searchsubmit">Search</button>
</form>
Good Code
<form role="search" method="get" id="searchform" class="searchform">
<label class="screen-reader-text" for="s">Search for:</label>
<input type="text" value="" name="s" id="s" />
<button type="submit" id="searchsubmit">Search</button>
</form>
Skip to Content Link
Let keyboard navigators skip TABing through menus.
Skip Link HTML
<body>
<a href="#primary" class="screen-reader-text assistive-text">Skip to Main Content</a>
<!-- Stuff like menus and banners -->
<main id="primary" tabindex="-1">...</main>
</body>
Assistive Text :focus
CSS
.assistive-text:focus {
clip: auto;
width: auto;
height: auto;
z-index: 100000;
/* make it pretty too! */
}
Facilitate Accessibility Example: User-set alt
attribute
The Wrong Way
<?php printf( '<img src="%1$s">',
esc_url( wp_get_attachment_image_src( $id ) )
); ?>
<img src="#">
The Right Way
<?php echo wp_get_attachment_image( $id ); ?>
<img src="#" alt="{User-set alt attribute!}">
WordPress + Accessibility = #WPa11y
#WPa11y Community
- Make WordPress Accessible Team
- Individuals who blog / tweet / speak: (Just a small sample!)
#WPa11y Guidelines & Code
Accessibility Plugins
- WP AccessibilitySuite of accessibility tweaks
- Access Monitor (integrates Tenon.io)Automated accessibility audits
- ".screen-reader-text" theme supportAdds front-end
.screen-reader-text
class for themes that don't have it. - Gravity Forms - WCAG 2.0 form fieldsMakes Gravity Forms more accessible
- Contact Form 7 Accessible DefaultsMakes Contact Form 7 more accessible
- Genesis AccessibleMakes Genesis theme framework more accessible
- Plugins with "accessibility" tag
More Accessibility Resources

General Accessibility Resources
- The Accessibility Project
- WebAIM
- Web Accessibility Initiative's (WAI) Web Content Accessibility Group (WCAG) Guidlines
- Usability.gov
Accessibility Blogs
There are many, these are just some of my favorites.
Testing for Accessibility
- Navigate with your Keyboard (TAB, SHIFT+TAB, ENTER, SPACE, ARROW KEYS)
- WAVE Toolbar
- Screen readers! Apple Voiceover. NVDA. Chrome Vox.
- FANGS for Firefox.
- Contrast Checker, Color Contrast Analyzer, and NoCoffee
- Chrome Accessibility Dev Tools
- More tool suggestions from the WordPress Accessibility Team
A Few More Parting Tips…
Title
attributes are mostly useless.- Opening links in new tabs/windows was never a "best practice."
placeholder
s are NOTlabel
s- The HTML5 Document Model isn't accessible (still).
- One
<h1>
per page!
- One
- Don't use autoplay! (Videos, Sliders, GIFs)
- Beware of slideshows/carousels/sliders. They are terrible for so many reasons!
- HTML is an accessibility framework.
<a>
,<button>
,<nav>
,<h1>
,<input type="checkbox">
, etc. come with #a11y built in!
- For interactive elements, use ARIA attributes.
Do Your Part!
- Code: Make your websites accessible.
- Englighten: Make the web accessible.
- Inspire: "Democratize" web publishing!

In Other Words…
WordPress
+
Accessibility
=
Happy
Internet
(Yes, all those icons have text alternatives!)
Colophon
- Slides made with Deck.js with "Swiss" theme
- Syntax highlighting via the SyntaxHighlighter library
- Icons from Dashicons
- This presentation is licensed under Creative Commons Attribution-NonCommercial 4.0 International