ARIA and Progressive Enhancement

For seven years, we’ve held tightly to the belief that using progressive enhancement is the right way to build websites and applications. Progressive enhancement is how we build sustainable, interoperable, and accessible web solutions.
You’ve seen this before. You…
  1. start with pristine, semantic HTML,
  2. provide a layer of presentational suggestions via CSS (these may or may not be overridden by user styles), and
  3. provide a layer of behavioral enhancements with JavaScript (again, these may or may not be overridden or supplemented by user scripts).
At each step along the way, we have what amounts to a working solution. We build each working solution on top of other, already working solutions.
Now that the release of ARIA is approaching, let’s take a look at how ARIA fits within progressive enhancement strategy. Can we use ARIA in a way that respects progressive enhancement? Can we use ARIA in ways that ensure we have a working solution at every level?

ARIA simplified

ARIA is an emerging specification from the W3C and is an accessibility effort that a number of companies support. ARIA is designed to provide accessibility at a technical level—what you might call “programmatic accessibility”—where it doesn’t already exist. For example, many of the date pickers and other advanced widgets that we add to our websites are nothing more than a collection of
and elements that have no semantic meaning; ARIA attempts to provide that semantic meaning.
Keep in mind that ARIA is still not quite finished—it is, as of this writing, published as a working draft and is under review. This is how specs work. In fact, if you read Martin Kliehm’s 2007 article from ALA 235, Accessible Web 2.0 Applications with WAI-ARIA you’ll see that quite a bit has changed. The general ARIA concepts are still the same, but the current implementation is much simpler and will be much easier to use.
Eventually, implementing ARIA in our designs will allow us to reliably tell assistive technology “this div is actually a dialog box” or “this ordered list of links is actually a menu of choices” or “this collection of divs, images, and spans is a progress bar, and that progress bar is currently at 75%.”
ARIA offers three means to do this. They allow us to communicate:
  • what role a particular component has in the interface,
  • the properties that component has, and
  • the current state of the component.
We do this by using ARIA attributes and values just like we use any other HTML attribute and value, but we modify them with scripting in response to events that happen within the browser. Some of what ARIA provides also helps to establish programmatic relationships between parts of the interface, but we’ll leave that for later.

ARIA in the wild

We recently relaunched Simply Accessible, a home for all of our accessibility-related writing. In the site code we used ARIA landmark roles to provide a standardized set of navigational landmarks within the page. If you look at a sample article page such as Custom Stylesheets for iOS, the article pages have the following landmark roles defined in their code:
  • role="banner" for the masthead of the site,
  • role="navigation" for each of the navigation lists at the top and bottom of the page,
  • role="search" for the search form,
  • role="main" for the main content of the page,
  • role="complementary" for the related information in the sidebar, and
  • role="contentinfo" for the copyright statement at the bottom.
This code allows assistive technology that understands ARIA landmarks to move from one landmark to another using keyboard shortcuts (as with the JAWS screen reader) or gestures (as with Apple’s VoiceOver).
Here’s another example of ARIA in action: A slider widget on a Google Map. In this implementation of a Google Map, we’ve added ARIA to the slider control that allows you to change zoom levels. We added ARIA to this quite simply because there is no native HTML element for a slider—we have to construct it from the tools we have. So, to approximate a real slider that you might see at the operating system level, we added ARIA to the basic HTML markup. Here we have:
  1. indicated a role for the component (role="slider"),
  2. used aria-orientation="vertical" to specify that it is…wait for it…oriented vertically, and,
  3. added several properties to that slider (aria-valuemin="0", aria-valuemax="17", aria-valuetext="14", and aria-valuenow="14").
As we slide the thumb along the rail to change the zoom level, we use JavaScript to change the value of aria-valuenow and aria-valuetext to match the zoom level.
Showing the aria-valuetext and aria-valuenow with the value of 12 Fig 1. Showing the aria-valuetext and aria-valuenow with the value of 12.
You can see this for yourself using Firebug or another developer tool. Figure 1 shows the aria-valuetext and aria-valuenow highlighted with a value of 12, matching the zoom level from the maps themselves. With JavaScript on, those values update dynamically as you zoom in or out. For true progressive enhancement, you would create a version that uses a form submission to select a zoom level and uses the Google Maps Static API, which doesn't require JavaScript.
In typical ARIA implementations such as these:
  1. simple ARIA role attributes define the role for various parts of the page: role="menu", role="dialog", role="navigation", and role="tablist",
  2. simple ARIA properties define connections between various interface components: aria-labelledby="someid", aria-describedby="anotherid", aria-haspopup="true", and
  3. simple ARIA states define the current state of objects on the page: aria-hidden="true", aria-invalid="false", aria-disabled="true", aria-expanded="false".
Go straight to the source for full details on all the ARIA roles and states and properties.
To use ARIA, we’ll need several different pieces of the puzzle to fall into place. As you saw in the slider example, we need to add ARIA attributes to our HTML and then control them with JavaScript as we dynamically update the page.
Support for ARIA isn’t quite that simple, though. Yes, we can add ARIA to provide “semantic sugar,” but there is more to it than that.
Accessibility requires everyone—authors and content creators, browser vendors, assistive technology vendors, and the person using the site or app—to come to the table with the right tools.

What are the right tools for ARIA?

Some browsers have some support for ARIA. Current versions of Firefox 3, Opera 9.5+, IE8/9, and WebKit-based browsers like Safari 4+ all support some aspects of ARIA. Of course, their support isn’t complete. It can’t be, simply because the spec isn’t finished.
Some assistive technology has some support for ARIA. Current versions of JAWS, Window-Eyes, NVDA, VoiceOver, and ZoomText have some support for ARIA, but older versions, naturally, don’t.

Rubber, meet road

A really simple way to start implementing ARIA is by using ARIA’s landmark role concept.
You’ve already seen this if you looked at our Simply Accessible site. But there are a few other things to note in that page relative to progressive enhancement.
Let’s just take a look at one example—the role of “navigation.”
Here’s how we’ve coded the navigation in the

and the
sections of the site.

 

You might be asking “Why on earth is there a role of navigation on an element called

No comments:

Post a Comment

Flag Counter