Intro to Web Accessibility
Class 2
Welcome!
Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
Some "rules"
We are here for you!
Every question is important
Help each other
Have fun
What is accessibility?
Accessibility is about making your sites useful to as many people as possible.
Accessibility is about overcoming barriers.
Accessibility is about helping your users.
Accessibility in the Real World
VIDEO
This video introduces many concepts we are talking about today with poor implementation of features on the web with some bad humor. Watch first 4ish minutes.
What are the common problems users face on the web?
Screen reader user survey
The most problematic items according to the WebAIM survey in 2017 are:
CAPTCHA - images presenting text used to verify that you are a human user.
Screens or parts of screens that change unexpectedly.
Links or buttons that do not make sense.
Images with missing or improper descriptions (alt text).
The presence of inaccessible Flash content.
Lack of keyboard accessibility.
Complex or difficult forms.
Missing or improper headings.
Too many links or navigation items.
Complex data tables.
Inaccessible or missing search functionality.
Lack of "skip to main content" or "skip navigation" links.
Source: WebAIM Screen Reader Survey, October 2017 opens in a new window
Introduce the WebAIM Screen Reader survey and show the common problems. Marcy's version of the infographic highlights topics covered in the two classes. This can be helpful to keep open in a second browser tab so it can be referenced more than once.
How do I code for accessibility?
HTML
Headings
Buttons
Form Labels
Text Alternatives
Tab Index
External link indicators
Semantic HTML
Use HTML elements that have meaning.
Elements have default behavior.
Semantic structure is one of the most important usability features for screen reader users, as it helps them more easily understand and navigate the page structure.
MDN Document on HTML elements opens in a new window
HTML Headings
Headings also help all your users understand the content.
We can think about headings like an outline for a paper.
Headings should not skip levels
<h1>Most important</h1>
<h2>Next most important</h2>
<h3>Third most important</h3>
<h4>Other heading</h4>
Read more about headings opens in a new window
Let's Develop It
What is and isn't a button?
Take a look at the button demo codepen opens in a new window
Buttons are often coded poorly on the web by adding click events to other elements where a button would have worked best. The codepen linked shows 4 examples of how a button could be coded but only the 4th button is an actual button.
Form Labels
How do they work?
Let's develop it
Add labels to an HTML form
Explicit association - label for
<label for="name-field">Label</label>
<input type="text" id="name-field" name="name-field">
You can also implicitly associate the label with the input field.
<label>Label
<input type="text" name="name-field">
</label>
Add a label to the form in input field demo codepen opens in a new window .
Other tips for forms
Don't use placeholder text as the label.
Provide good instructions, labels, validation, and errors.
The form should be keyboard accessible.
Allow the user to easily correct their mistakes.
Creating Accessible Forms opens in a new window
External Links
Provide affordances to warn users of unexpected screen changes
External Links
Let's Develop It
Here's one way of letting users know a link opens in a new tab.
<a href="goofy.html">Goofy page<a>
<a href="http://disney.com" target="_blank"
title="Link opens in a new window"
class="external-link">
Disney.com
<span class="offscreen">
opens in a new window
</span>
</a>
A common problem cited in the WebAIM survey is “unexpected screen changes”. Discuss how to warn users of links that open in new windows with offscreen text and title attributes. Include a discussion about how it's really about usability in general. Recommended reading: “Don't Make Me Think” by Steve Krug
Tab Index
The tabindex attribute explicitly defines the tab order for focusable elements (typically links and form controls) within a page.
It can be used to define whether elements should be focusable.
Don't use tab index values greater than 0
Read more about tabindex on WebAIM opens in a new window
Source: http://reference.sitepoint.com/html/a/tabindex
Explain tab order. Show a demo of tabIndex=”” attributes on native and non-native elements to show how it affects the flow of a document (anchor, input, div, heading, etc.). Explain tab index values of -1, 0 and 1+ their specific purposes
Tab Index
Let's Develop It
Explore tab index on native (buttons, links, ect.) and non-native elements.
Play with tab index in the tab index demo codepen opens in a new window or try tabbing through this slide
Explain how tabindex -1 causes the element to only be focusable by script. It takes it out of the tab order entirely. This is useful for focusing on form errors.
How do I code for accessibility?
CSS
CSS can be used to alter visual appearance, but should never change the structure or ordering of the page content.
Visually Hidden Content
Really Hidden
Background Images
Visually Hidden Content
This is one way to provide data for screen reader users and hide for sighted users
/*Copied from HTML5 Boilerplate*/
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
Hiding Content for Accessibility opens in a new window
Background Images
Only use decorative images as background images
No alternative text is available
Don't forget to consider contrast of text on top of images
Example code
#animalImage {
background-image: url('animal-drums-copia.jpg');
background-repeat: no-repeat;
}
What else can we do with CSS?
Implement good color contrast
Use padding and margins for space instead of using extra markup
Style focus states for links and buttons
a {
color: #01a9b4;
}
a:hover, a:focus {
color: #f3787e;
}
How do I code for accessibility?
Accessible Rich Internet Applications
Expands HTML's functionality.
Define behavior of custom widgets.
Communicates state and purpose to assistive technologies.
ARIA gives information to screen readers, but doesn't tell browsers or assistive technologies what to do with it.
What is WAI-ARIA, what does it do for me, and what not? opens in a new window
ARIA Core Components
Roles
What does this thing do?
<form role="search">
States
The current condition of this particular thing
<input aria-disabled="true">
Properties
The nature of the thing
<input aria-required="true">