YUI Library Home

YUI Library Examples: AutoComplete Control: Screenreader Accessibility

AutoComplete Control: Screenreader Accessibility

This AutoComplete example demonstrates how to make the widget more screenreader accessible.

 

There are a few simple things you should do to make your AutoComplete implementation more screenreader accessible.

Label your input field

First, provide a label element for your input field. Within this label, you can include a span that is styled via CSS to be displayed offscreen with helpful text that screenreaders will read aloud.

Insert the screenreader label text dynamically

If you insert the span element that holds the screenreader text into the label dynamically at runtime, most screenreaders will read it aloud each time only when the user focuses on the input for a new AutoComplete interaction, instead of during regular page browsing.

Enable the typeAhead feature

By setting your AutoComplete's typeAhead property to true, screenreaders (in focus mode) will read aloud each suggestion as the user navigates them with the up and down arrow keys.

Disable the autoHighlight feature

By default, AutoComplete's autoHighlight property is enabled, which may add confusion when screenreaders read aloud the first suggestion when it is autohighlighted. To avoid this scenario, disable the autoHighlight feature.

Sample Code

Markup:

JavaScript:

Configuration for This Example

You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.

Copyright © 2010 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings