GHC Web Accessibility Workshop

Set Up

The steps below will help you get set up for the activities in this workshop:
  1. Click here to download the workshop materials: https://github.com/ghc-2018-web-a11y/activities/archive/master.zip
  2. Extract the downloaded zip file.
  3. Open index.html in Chrome (the activity may have limited compatibility in other browsers). NOTE: If you already feel comfortable using a screen reader on your machine, open index_no_screenreader.html instead.
  4. Also open the following files in your favorite text editor: main.js, main.css, index.html (or index_no_screenreader.html depending on the file you opened in Chrome above).

Activity Tips

Follow these tips to get the most out of these activities!

Activity 1

You'll be using the index.html (or index_no_embedded_screenreader.html) file you have open in Chrome for this activity. On index.html you should see a lightweight embedded screenreader across the bottom of the page, which which was originally built for an awesome Udacity course on web accessibility (see link in resources below).

Use just the screen reader shortcuts (displayed in the image below), as well as the enter, tab and shift+tab keys to explore the HTML page you have open in your browser. To simulate how a user relying on a screen reader would interact with the page, don't use your mouse!
Buttons provided by the screen reader to navigate the page

This table contains all the shortcuts you'll need to use as you interact with the page:

Shortcut or button Functionality
Tab key Navigate to next interactive element
Shift + Tab keys Navigate to previous interactive element
Enter Click on selected links or buttons
Headings button Navigate to next heading (e.g. h1, h2, h3 elements)
Next button Navigate to next element
Previous button Navigate to previous element

Are you able to interact with the page using just your keyboard as effectively as a sighted user using a mouse would be able to?

Remember that there are some things about this page that are purposely broken from an accessibility standpoint. If you notice any, note them down; you'll get a chance to fix some of them in exercise 2.

Here are some examples you can try:

Once you've finished exploring, sit tight and we'll let you know when it's time to start Activity 2!

Activity 2

For this activity, you'll still need the HTML file open in your browser from Activity 1. Also, make sure you have 3 files (the HTML, Javascript, and CSS files) open in a text editor. Check out the Quick Frontend Dev Intro by clicking the button below if you need help with that!

We'll be fixing accessibility issues in this activity.

You'll need to use your text editor to make modifications to the HTML, Javascript, and CSS files (but mostly just the HTML). To test the changes you have made, save the files and then refresh the HTML page you have open in your browser.

Exercise 1: Headers

Screen-reader-users rely on screen readers vocalizing what types of elements they are interacting with (e.g. "button" or "header"). Without these vocalizations, it's more difficult for users to make their way around a page and distinguish between different kinds of content.

Real screenreaders have a variety of keyboard shortcuts used to navigate different kinds of elements on a page (e.g. 'b' might cycle through all buttons, or 'h' through all headers). The heading shortcut is very important for building a mental map of how the page is laid out, and help make the page faster to navigate as users can quickly skip to the content they are interested in.

Use the "heading" button at the bottom of the website to navigate all of the headers on the page. Notice that this allows you to navigate most of the headings on the site -- except for the site title (which reads "Online Garage Sale)! Take a look at the HTML for the headers to see if you can figure out what's wrong with the site title and fix it.

Exercise 2: Tabbing

Screenreader and non-screenreader-users alike often use tab and shift+tab for navigating between interactive elements. It's important to always make sure that this functionality works correctly in addition to navigating by screenreader shortcuts.

Try using the 'tab' key to navigate the demo page. You'll notice that the "Hand Painted Jar" cannot be focused. Compare the untabbable element to other elements on the page and see if you can figure out how to make it tabbable.

Exercise 3: Broken Buttons

To buy an item on this page, a user must select the "BUY" button. Users who are using a mouse may select this button using their mouse. Users who are using the keyboard, however, must be able to interact this button by moving focus to it and using the "enter" key to select it.

Try using the tab key to navigate to the "BUY" buttons. You'll notice that these buttons cannot gain focus. Since the buttons can't gain focus, a user navigating with a screen reader or keyboard is unable to interact with them.

If you hover over one of these buttons with the mouse, you'll also notice that the cursor doesn't change to the "default" cursor that is typical of buttons. Why do you think this might be (hint: take a look at the HTML)? Modify the HTML to see if you can fix the "BUY" buttons.

Exercise 4: ARIA labels

Open the buy dialog and use tab to navigate to the "X" button. If you completed the last exercise, this button should now be navigable. Does the screen reader's vocalizattion of the button help determine what the button's purpose might be? You'll notice that the screen reader just describes the button as a "button button", which is not a helpful description.

An aria-label can be used to attach an alternative description to elements. This is particularly useful when the text inside an element is not sufficient to describe the element, as is commonly the case with icon buttons. Use this attribute to fix the vocalization of the "X" button inside the buy dialog.

Exercise 5: ARIA roles

Sometimes, for whatever reason, you can't use the correct native HTML elements. You may need to support legacy browsers that will have issues with the new HTML element, or there are other technical limitations. In these cases, you can use an ARIA role to still get the proper screenreader vocalizations. Let's try it out!

Take the first button you modified in exercise 3 (the button corresponding to the elephant figurine), change it back to a div, and add role="button" as an attribute. How do you think this might be different from a native button element?

Exercise 6: Visibility

You have probably noticed that there's an invisible dialog at the bottom of the screen that gets vocalized even though it's not showing. To reproduce this issue, try using tab to navigate though all the items on the page, and notice that there are a few items at the very end that are invisible to the eye, but navigable by screen reader.

This is problematic, since non-sighted users will assume that the dialog is visible (and it may not function correctly since the developer did not intend for it to be interacted with in this state), and users with some vision will be confused when an element that they can hear is not visible on the screen.

Try hiding the dialog from screenreaders. There are several different solutions! Hint: Try taking a look at main.css.

Exercise 7: Dialogs

Using a screen reader, navigate to the "buy" dialog and tab through the various input fields inside the dialog. You'll notice a few issues with navigating the dialog using the screen reader, such as:

  1. There is no indication or announcement by the screen reader when the dialog opens.
  2. Focus is mismanaged. Once the dialog opens, focus is still unexpectedly in the background of the page.

Fix the dialog using a combination of HTML and JavaScript. This exercise is a little tricky, so feel free to click the button below for help and/or take a look at the solution directory!

Bonus Exercise 8: Advanced ARIA

ARIA comes in very handy when you're implementing a complex widget for which no native markup exists. For instance, if you're implementing a slider or an autocomplete, you need some way of concisely communicating to the user what the widget does and how to interact with it.

You'll notice that at the bottom of the "BUY" dialog is a tab widget. However, without aria roles and properties, screenreader users may not know how to interact with it. Using the ARIA spec, try adding the proper ARIA markup!

Hint: You'll need to use javascript to update the markup when the tab selection changes.

Bonus Exercise 9: Color contrast

Even though we've fixed the functionality of the buttons, they're still not quite fully accessible due to their low color contrast. The gray text (#808080) is difficult to discern from the blue (#0000FF) background.

Check out the WebAIM Contrast Checker to learn more.

Try different color combinations and modify the color or background-color attributes on the buttons to get a better color contrast ratio!

WCAG 2.0 level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text. Level AAA requires a contrast ratio of at least 7:1 for normal text and 4.5:1 for large text.

Large text is defined as 14 point (typically 18.66px) and bold or larger, or 18 point (typically 24px) or larger.

source: https://webaim.org/resources/contrastchecker/

Don't be afraid to push back on designs that use colors that have color contrast ratios that are too low!

Learn more

If you'd like to learn more about how to create accessible web components, visit the MDN documentation on ARIA techniques.

Additional Resources

Resources for later

Documentation

How to use your screenreader