1 <h1>Accessibility (a11y)
</h1>
5 When you design an extension,
6 try to make it as accessible as possible
7 to people with disabilities such as
8 visual impairment, hearing loss, and limited dexterity.
12 Everyone
— not just people with special needs
—
13 can benefit from the alternative access modes
14 that accessible extensions provide.
15 For example, keyboard shortcuts are important
16 for blind people and people with limited dexterity,
17 but they also help power users get things done
18 more quickly without using a mouse.
19 Captions and transcripts give deaf people access to audio content,
20 but they are also useful to language learners.
24 People can interact with your extension in a variety of ways.
25 They might use a standard monitor, keyboard, and mouse,
26 or they might use a screen magnifier and just a keyboard.
27 Another possibility is a
<em>screen reader
</em>,
28 an assistive application tool that interprets
29 what's displayed onscreen
30 for a blind or visually impaired user.
31 A screen reader might speak out loud or produce Braille output.
35 Although you can't predict what tools people will use,
36 by following a few simple guidelines
37 you can write an extension that is
38 more likely to be accessible to more people.
39 The guidelines on this page aren't going to
40 make your extension accessible for absolutely everyone,
41 but they're a good starting point.
45 <h2 id=
"controls">Use accessible UI controls
</h2>
48 First, use UI controls that support accessibility.
49 The easiest way to get an accessible control is to use a
50 standard HTML control.
51 If you need to build a custom control,
52 keep in mind that it's much easier
53 to make the control accessible from the beginning
54 than to go back and add accessibility support later.
57 <h3 id=
"htmlcontrols">Standard controls
</h3>
60 Try to use standard HTML UI controls whenever possible.
61 Standard HTML controls (shown in the following figure)
62 are keyboard accessible, scale easily,
63 and are generally understood by screen readers.
66 <img src=
"{{static}}/images/a11y/standard-html-controls.png"
67 width=
"550" height=
"350"
68 alt=
"Screenshots and code for button, checkbox, radio, text, select/option, and link">
71 <h3 id=
"aria">ARIA in custom controls
</h3>
74 ARIA is a specification for making UI controls accessible to screen readers
75 by means of a standard set of DOM attributes.
76 These attributes provide clues to the screen reader
77 about the function and current state of controls on a web page.
79 <a href=
" http://www.w3.org/WAI/intro/aria">work in progress at the W3C
</a>.
83 Adding ARIA support to custom controls in your extension
84 involves modifying DOM elements to add attributes
86 to raise events during user interaction.
87 Screen readers respond to these events
88 and describe the function of the control.
89 The DOM attributes specified by ARIA are classified into
90 <em>roles
</em>,
<em>states
</em>, and
<em>properties
</em>.
94 The ARIA attribute
<em>role
</em>
95 is an indication of the control type
96 and describes the way the control should behave.
97 It is expressed with the DOM attribute
<code>role
</code>,
98 with a value set to one of the pre-defined ARIA role strings.
99 Because ARIA roles are static,
100 the role attribute should not change its value.
104 The
<a href=
"http://www.w3.org/WAI/PF/aria/roles">ARIA Role Specification
</a>
105 holds detailed information on how to pick the correct role.
106 For example, if your extension includes a toolbar,
107 set the
<code>role
</code> attribute of the toolbar's DOM element as follows:
111 <div
role=
"toolbar">
115 ARIA attributes are also used to describe
116 the current state and properties of controls of a particular role.
117 A
<em>state
</em> is dynamic and should be updated during user interaction.
118 For example, a control with the role
"checkbox"
119 could be in the states
"checked" or
"unchecked".
120 A
<em>property
</em> is not generally dynamic,
121 but is similar to a state
122 in that it expresses specific information about a control.
123 For more information on ARIA states and properties,
125 <a href=
"http://www.w3.org/TR/wai-aria/states_and_properties">W3C States and Properties specification
</a>.
131 You don't have to use
132 all of the states and properties available for a particular role.
136 Here's an example of adding
137 the ARIA property
<code>aria-activedescendant
</code>
138 to the example toolbar control:
142 <div
role=
"toolbar" tabindex=
"0" aria-activedescendant=
"button1">
147 <a href=
"http://www.w3.org/WAI/PF/aria/states_and_properties#aria-activedescendant"><code>aria-activedescendant
</code></a>
148 property specifies which child of the toolbar receives focus
149 when the toolbar receives focus.
150 In this example, the toolbar's first button
151 (which has the
<code>id
</code> "button1")
152 is the child that gets focus.
153 The code
<code>tabindex=
"0"</code>
154 specifies that the toolbar
155 receives focus in document order.
159 Here's the complete specification for the example toolbar:
163 <div
role=
"toolbar" tabindex=
"0" aria-activedescendant=
"button1">
164 <img
src=
"buttoncut.png" role=
"button" alt=
"cut" id=
"button1">
165 <img
src=
"buttoncopy.png" role=
"button" alt=
"copy" id=
"button2">
166 <img
src=
"buttonpaste.png" role=
"button" alt=
"paste" id=
"button3">
171 Once ARIA roles, states, and properties are added to the DOM of a control,
172 Google Chrome raises the appropriate events to the screen reader.
173 Because ARIA support is still a work in progress,
174 Google Chrome might not raise an event for every ARIA property,
175 and screen readers might not recognize all of the events being raised.
176 You can find more information on ARIA support in Google Chrome in the
177 <a href=
"http://www.chromium.org/developers/design-documents/accessibility#TOC-WAI-ARIA-Support">Chromium Accessibility Design Document
</a>.
181 For a quick tutorial on adding ARIA controls to custom controls, see
182 <a href=
"http://www.w3.org/2010/Talks/www2010-dsr-diy-aria/">Dave Raggett's presentation from WWW2010
</a>.
184 <h3 id=
"focus">Focus in custom controls
</h3>
187 Make sure that operation and navigation controls of your extension
188 can receive keyboard focus.
189 Operation controls might include
190 buttons, trees, and list boxes.
191 Navigation controls might include tabs and menu bars.
195 By default, the only elements in the HTML DOM
196 that can receive keyboard focus
197 are anchors, buttons, and form controls.
198 However, setting the HTML attribute
<code>tabIndex
</code> to
<code>0</code>
199 places DOM elements in the default tab sequence,
200 enabling them to receive keyboard focus.
205 <em>element
</em>.tabIndex =
0
209 Setting
<code>tabIndex = -
1</code> removes the element from the tab sequence
210 but still allows the element to receive keyboard focus programmatically.
211 Here's an example of setting keyboard focus:
215 <em>element
</em>.focus();
219 Ensuring that your custom UI controls include keyboard support
220 is important not only for users who don't use the mouse
221 but also because screen readers use keyboard focus
222 to determine which control to describe.
225 <h2 id=
"keyboard"> Support keyboard access
</h2>
228 People should be able to use your extension
229 even if they can't or don't want to use a mouse.
232 <h3 id=
"navigation"> Navigation
</h3>
235 Check that the user can navigate between
236 the different parts of your extension
237 without using the mouse.
238 Also check that any popups on page actions or browser actions
239 are keyboard navigable.
243 On Windows, you can use
<b>Shift+Alt+T
</b>
244 to switch the keyboard focus to the toolbar,
245 which lets you navigate to the icons of page actions and browser actions.
247 <a href=
"https://support.google.com/chrome/answer/157179">Keyboard and mouse shortcuts
</a>
248 lists all of Google Chrome's keyboard shortcuts;
249 details about toolbar navigation
250 are in the section
<b>Google Chrome feature shortcuts
</b>.
255 The Windows version of Google Chrome
6 was the first
256 to support keyboard navigation to the toolbar.
257 Support is also planned for Linux.
259 access to the toolbar is provided through VoiceOver,
260 Apple's screenreader.
264 Make sure that it's easy to see
265 which part of the interface has keyboard focus.
266 Usually a focus outline moves around the interface,
267 but if you’re using CSS heavily this outline might be suppressed
268 or the contrast might be reduced.
269 Two examples of focus outline follow.
272 <img src=
"{{static}}/images/a11y/focus-outline-2.png"
273 width=
"200" height=
"75"
274 alt=
"A focus outline on a Search button">
276 <img src=
"{{static}}/images/a11y/focus-outline.png"
277 width=
"400" height=
"40"
278 alt=
"A focus outline on one of a series of links">
281 <h3 id=
"shortcuts"> Shortcuts
</h3>
284 Although the most common keyboard navigation strategy involves
285 using the Tab key to move focus through the extension interface,
286 that's not always the easiest or most efficient way
287 to use the interface.
288 You can make keyboard navigation easier
289 by providing explicit keyboard shortcuts.
293 To implement shortcuts,
294 connect keyboard event listeners to your controls.
295 A good reference is the DHTML Style Guide Working Group’s
296 <a href=
"http://dev.aol.com/dhtml_style_guide">guidelines for keyboard shortcuts
</a>.
300 A good way to ensure discoverability of keyboard shortcuts
301 is to list them somewhere.
303 Your application's options page
306 <a href=
"options">Options page
</a>
308 might be a good place to do this.
312 For the example toolbar,
313 a simple JavaScript keyboard handler could look like the following.
314 Note how the ARIA property
<code>aria-activedescendant
</code>
315 is updated in response to user input
316 to reflect the current active toolbar button.
322 function optionKeyEvent(event) {
323 var tb = event.target;
329 // Partial sample code for processing arrow keys.
330 if (event.type ==
"keydown") {
331 // Implement circular keyboard navigation within the toolbar buttons
332 if (event.keyCode == ENTER_KEYCODE) {
333 ExecuteButtonAction(getCurrentButtonID());
334 <em>// getCurrentButtonID defined elsewhere
</em>
335 } else if (event.keyCode == event.RIGHT_KEYCODE) {
336 // Change the active toolbar button to the one to the right (circular).
337 var buttonid = getNextButtonID();
338 <em>// getNextButtonID defined elsewhere
</em>
339 tb.setAttribute(
"aria-activedescendant", buttonid);
340 } else if (event.keyCode == event.LEFT_KEYCODE) {
341 // Change the active toolbar button to the one to the left (circular).
342 var buttonid = getPrevButtonID();
343 <em>// getPrevButtonID defined elsewhere
</em>
344 tb.setAttribute(
"aria-activedescendant", buttonid);
353 <div
role=
"toolbar" tabindex=
"0" aria-activedescendant=
"button1" id=
"tb1"
354 onkeydown=
"return optionKeyEvent(event);"
355 onkeypress=
"return optionKeyEvent(event);">
356 <img
src=
"buttoncut" role=
"button" alt=
"cut" id=
"button1">
357 <img
src=
"buttoncopy" role=
"button" alt=
"copy" id=
"button1">
358 <img
src=
"buttonpaste" role=
"button" alt=
"paste" id=
"button1">
363 <h2 id=
"more"> Provide accessible content
</h2>
367 The remaining guidelines might be familiar
368 because they reflect good practices for all web content,
372 <h3 id=
"text">Text
</h3>
375 Evaluate your use of text in your extension.
376 Many people might find it helpful
377 if you provide a way to increase the text size within your extension.
378 If you are using keyboard shortcuts,
379 make sure that they don't interfere with
380 the zoom shortcuts built into Google Chrome.
384 As an indicator of the flexibility of your UI,
385 apply the
<a href=
"http://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-scale">200% test
</a>.
386 If you increase the text size or page zoom
200%,
387 is your extension still usable?
391 Also, avoid baking text into images:
392 users cannot modify the size of text displayed as an image,
393 and screenreaders cannot interpret images.
394 Consider using a web font instead,
395 such as one of the fonts collected in the
396 <a href=
"http://code.google.com/apis/webfonts/">Google Font API
</a>.
397 Text styled in a web font is searchable,
398 scales to different sizes,
399 and is accessible to people using screen readers.
402 <h3 id=
"colors">Colors
</h3>
405 Check that there is sufficient contrast between
406 background color and foreground/text color in your extension.
407 <a href=
"http://snook.ca/technical/colour_contrast/colour.html">This contrast checking tool
</a>
408 checks whether your background and foreground colors
409 provide appropriate contrast.
410 If you’re developing in a Windows environment,
411 you can also enable High Contrast Mode
412 to check the contrast of your extension.
413 When evaluating contrast,
414 verify that every part of your extension that relies on
415 color or graphics to convey information is clearly visible.
416 For specific images, you can use a tool such as the
417 <a href=
"http://www.vischeck.com/vischeck/">Vischeck simulation tool
</a>
418 to see what an image looks like in various forms of color deficiency.
422 You might consider offering different color themes,
423 or giving the user the ability to customize the color scheme
427 <h3 id=
"sound">Sound
</h3>
430 If your extension relies upon sound or video to convey information,
431 ensure that captions or a transcript are available.
433 <a href=
"http://www.dcmp.org/ciy/">Described and Captioned Media Program guidelines
</a>
434 for more information on captions.
437 <h3 id=
"images">Images
</h3>
440 Provide informative alt text for your images.
445 <img
src=
"img.jpg" alt=
"The logo for the extension">
449 Use the alt text to state the purpose of the image
450 rather than as a literal description of the contents of an image.
451 Spacer images or purely decorative images
452 should have blank (
"") alt text
453 or be removed from the HTML entirely and placed in the CSS.
457 If you must use text in an image,
458 include the image text in the alt text.
459 A good resource to refer to is the
460 <a href=
"http://www.webaim.org/techniques/alttext/">WebAIM article on appropriate alt text
</a>.
462 <h2 id=
"examples">Examples
</h2>
465 For an example that implements keyboard navigation and ARIA properties, see
466 <a href=
"http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/extensions/news_a11y/">examples/extensions/news_a11y
</a>
468 <a href=
"http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/extensions/news/">examples/extensions/news
</a>).
469 For more examples and for help in viewing the source code,
470 see
<a href=
"sampleshtml">Samples
</a>.