Archive for May, 2011

ARIA-Landmark

Tuesday, May 31st, 2011

ARIA Landmarks are a good substitute for skip links, and allow the user to skip not just over repetitive navigation but to move directly to the various parts of a web page. The typical screen reader user must start reading at the top left of a page and continue line by line until the bottom right is reached. By using this simple convention, you can provide easy access to the main pieces of your page. And the syntax is very simple to use. This is one easy thing you can do to increase accessibility for the screen reader user.

ARIA landmarks are actually ARIA roles. And can be used like: role=”banner”.

JAWS provides several keyboard shortcuts for using ARIA Landmarks:

  • Move to Next Landmark – SEMICOLON.
  • Move to Previous Landmark – SHIFT+SEMICOLON.
  • Select a Landmark Item – INSERT+CTRL+SEMICOLON.
  • The following screen shot shows the JAWS window used to list all of the landmarks found on a page:
    Screen Shot of the JAWS Landmark List Window.

ARIA Landmarks available:

  • application – A region declared as a web application, as opposed to a web document.
  • banner – An area that contains things such as the logo or identity of the site sponsor, etc.
  • complementary – A supporting section of the document, designed to be complementary to the main content. Example: Sports News and Business News on a typical news page.
  • contentinfo – A region that contains information about the parent document. Example: copyrights and links to privacy statements.
  • form – A region of the document that represents a collection of form elements.
  • main – The main content of the document.
  • navigation – A collection of navigational elements. Example: A left navigation area.
  • search A region used to create a search widget.

ARIA Landmark Syntax: <div id=”content” role=”main”>

Example 1:

Code


<div id="doc"">
  <div id="header" role="banner">
    Banner/Header Area
  </div>
  <div id="search" role="search">
    Search Area
  </div>

  <div id="nav" role="navigation">
    Navigation Area
  </div>
  <div id="main_content" role="main">
    Main Content Area
  <div id="second_content" role="complementary">
      Complementary Content Area
  </div>
  <div id="footer" role="contentinfo">
    Content Info/Footer Area
  </div>
</div>

Works With

Using ARIA Landmarkd
Browser Screen Reader Results
IE 9 JAWS 12 Yes
FF 4 JAWS 12 Yes

Standards:

ARIA-Required

Tuesday, May 31st, 2011

ARIA Required (aria-required) indicates if a form field is required. The traditional method has been to add a “*” to the end of the fields’ LABEL text, and this is still recommended until all browsers and AT support the aria-required property.

aria-required uses “true” and “false” to indicate the property. “True” makes the field required, and “false” is not required.

Example 1:

Setting aria-required to true:



Code


<form action="submit.php">
<label for="firstname">First Name*</label>
<input type="text"
	id="firstname"
	name="firstname"
	size="50"
	aria-required="true">
 </form>

Example 2:

Setting aria-required to false has no effect on the screen reader:



Code


<form action="#">
<label for="title">Title</label>
<input 
  type="text" 
  id="title" 
  name="title" 
  size="50" 
  aria-required="false">
<label for="firstname">First Name*</label>
<input 
  type="text" 
  id="firstname" 
  name="firstname" 
  size="50" 
  aria-required="true">
 </p>
 </form>

Works With

Using ARIA REQUIRED
Browser Screen Reader Results
IE 9 JAWS 12 Yes
FF 4 JAWS 12 Yes

Standards:

ARIA Selected

Tuesday, May 24th, 2011

ARIA Selected (aria-selected) Indicates the current “selected” state of various widgets. However, it is not supported at the time of this article, however it can be simulated using the aria-label attribute.

Aria-selected is supported in roles gridcell, option, row, and tab. It’s possible values are true, false, undefined.

Example 1:

Code


 <ul>
	<li><a href="#" role="tab" aria-selected="true" aria-label="selected">Tab 1</a></li>
	<li><a href="#" role="tab" aria-selected="false"  aria-label="not selected">Tab 2</a></li>
	<li><a href="#" role="tab" aria-selected="undefined"  aria-label="not selected">Tab 3</a></li>
 </ul>

Works With

Using ARIA SELECTED
Browser Screen Reader Results
IE 9 JAWS 12 No
FF 4 JAWS 12 No

Standards:

  • WCAG 2.0 SC 4.1.2 Name, Role, Value: For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies. (Level A)
  • ARIA1: Using the aria-describedby property to provide a descriptive label for input controls or Instructions: Labels or instructions are provided when content requires user input. (Level A).
  • Aria-selected (state)

CSS Hide and Show

Friday, May 20th, 2011

The following example uses various CSS styles, dynamic Javascript and ARIA roles/properties to create an accessible accordion type hide/show area.

  • CSS hidden is used to hide the content.
  • CSS not_hidden is used to show the content.
  • CSS focus is used to highlight the current focused control with a yellow background.
  • Depending on the current state of the content (either hidden or not hidden) the Javascript setattribute method is used to:
    • dynamically change the arrow image from pointing down to right.
    • dynamically change the aria-expanded property to indicate the state of the accordion
    • dynamically change the aria-label property to indicate the state of the accordion, either open or closed (Just in case aria-expanded property is not supported in the current browser/AT).
    • dynamically change the class from hidden to not_hidden in order to hide and show the content.
    • dynamically move focus to an H tag inside the newly exposed content, causing the screen reader to speak and notify the user that content on the page has changed.
  • Other ARIA roles/properties used:
    • ARIA role is set to region.
    • ARIA role is set to button
    • Aria-labelledby is also used

Example 1:





Code


<style type="text/css">
.hidden {
    display: none;
    visibility: hidden;
}
.not_hidden {
	display: block;
	visibility: true;
}
:focus { 
	background-color:yellow;
}
</style>

<script language="JavaScript">
function ARIA_HideShow(e) {
	// Get the current class either hidden or not_hidden
	var getvalue=document.getElementById("ARIA_content").getAttribute("class");
	if (getvalue=="not_hidden")
	{
		// Set Image
		document.getElementById("arrow").setAttribute("src", "http://www.donaldevans.com/images/right_arrow.png");
		// Set the aria-label
		document.getElementById("myButton").setAttribute("aria-label","Drawer Collapsed. Click to expand.");
		// Set the aria-expanded
		document.getElementById("ARIA_content").setAttribute("aria-expanded","false");
		// Set the Class to hidden
		document.getElementById("ARIA_content").setAttribute("class","hidden");
		// Move Focus back to button
		document.getElementById("myButton").focus();
	} else {
	// Set Image
		document.getElementById("arrow").setAttribute("src","http://www.donaldevans.com/images/down_arrow.jpg");
		// Set the aria-label
		document.getElementById("myButton").setAttribute("aria-label","Drawer Expanded.  Click to collapse.");
		// Set the aria-expanded
		document.getElementById("ARIA_content").setAttribute("aria-expanded" , "true");
		// Set the Class to hidden
		document.getElementById("ARIA_content").setAttribute("class","not_hidden");
		// Move Focus to content
		document.getElementById("hTag").focus();
	}
}
</script>
<span>
<button id="myButton" 
    aria-label="Drawer Expanded.  Click to collapse." 
    aria-labelledby="myButton" 	
    onClick="ARIA_HideShow(event);" role="button">
      Drawer 
</button>
<img id="arrow" src="http://www.donaldevans.com/images/down_arrow.jpg" width="10" alt="">
</span>
<hr/>
<div id="ARIA_content" 
    class="hidden" 
    role="region" 
    aria-exanded="false" 
    tabIndex="-1">
    <h2 id="hTag" tabIndex="-1">
          Lorem ipsum
    </h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim 
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat 
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id 
est laborum.
</p>
</div>
<hr/>


Standards:

  • WCAG 2.0 SC 4.1.2 Name, Role, Value: For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies. (Level A)

Understanding How to Use CSS for Accessibility (Hiding Stuff)

Thursday, May 19th, 2011

For the most part screen readers don’t care about CSS. After all if you are a blind user, why do you want to know what color something is or where it is placed on the screen. This goes back to using HTML to mark up content, and using CSS to style the page. The screen reader generally only cares about the content.

There are a few exceptions. display: and invisible: are the two that stand out.

Example 1:

How to hide content from both screenreaders and visual users.

CSS Code


.hidden { 
display: none; 
visibility: hidden;
}

Example 2:

Hide only the visual content and let it be visable to the screen reader

CSS Code


.visuallyhidden { 
position: absolute; 
clip: rect(1px 1px 1px 1px); /* for IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
margin: -1px;
border: 0; 
padding: 0; 
width: 1px;
height: 1px ; 
overflow: hidden;
}

Example 3:

Extends the .visuallyhidden class to allow the element to be focusable when navigated to via the keyboard. Great to create a skip nav that is usable by the keyboard only user as well as the blind user.

CSS Code


.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus { 
clip: auto; 
height: auto; 
margin: 0; 
overflow: visible;
position: static; 
width: auto;
}

Standards:

ARIA Drag and Drop

Wednesday, May 18th, 2011

Drag and Drop operations have traditionally been very difficult for users who are blind, or otherwise cannot use a mouse. The ARIA Drag and Drop group of properties has solved the problem, although it is a bit cumbersome to implement.

ARIA uses aria-grabbed and aria-dropeffect to accomplish the task.

The Development Process

1. The developer must identify the draggable objects by setting the aria-grabbed to either true or false. Setting it to true indicates the object is grabbed. Setting it to false indicates it is draggable. Setting it to “” or “undefined” indicates it is not grabbable. Roles that support drag and drop are listitem and treeitem. The object must have a role declared for ARIA to work.

2. The developer must provide a way to select the draggable objects with the keyboard by setting the object’s aria_grabbed state to true. The JavaScript event onKeyDown can be used to detect if the user has selected an object by pressing the space key. Documentation also recommends using the Shift + Space to add a range of contiguous objects to the selection and control + shift to add non-contiguous items to the selection.

3. The developer must indicate the objects that can be drop targets using the aria-dropeffect. There are a number of properties that can be used to set aria-dropeffect:

  1. copy: A copy of the source object will be dropped on the target.
  2. move: The source object will be moved to the new location and removed from the orginial location.
  3. link: A shortcut link will be created.
  4. execute: the source is executed when it is dropped on the target.
  5. popup: Uses a popup menu that will let the user choose one of the other operations.
  6. none: No drop operation is supported. This is the default.

4. The developer is required to implement his/her own keyboard handlers to accomplish the dropping of the object. It is recommended that you follow the guidelines set out by the ARIA DHTML Styleguide. As an example, Control + M is used to drop once focus is on a droppable object. And ESC is used to cancle the operations.

5. After the operation the developer must:

  • Set all aria-dropeffect properties to “none” or remove them altogether.
  • Set all aria-grabbed of draggable objects to “false”.
  • Set all objects that are not grabbable must either omit the aria-grabbed property or have an aria-grabbed property set to “undefined”.
  • Set focus on the appropriate DOM element, and its role must also be determinable.

Note: The developer may want to consider adding a CSS style for the sighted keyboard only user to indicate visually what is draggable and where the drop points are located.

Alternative Method

The above steps are not for the faint of heart, and it takes a good knowledge of JavaScript to accomplish. So it may be appropriate to use an alternative approach. In fact, the alternative may be easier for screen reader users and keyboard only users.

As an example, if the task at hand envolves moving a picture to a album folder, you may want to provide a list of the pictures with check boxes that can be used to select all the images you wish to move. And then provide a drop down select list of the possible destination folders. This can be much easier in the long run.

Example 1: Creating a Draggable Object

Picture 1
Picture 2
Picture 3
Picture 4

Code


<div role="treeitem" aria-grabbed="false">Picture 1</div>
<div role="treeitem" aria-grabbed="true">Picture 2</div>
<div role="treeitem" aria-grabbed="undefined">Picture 3</div>
<div role="treeitem" aria-grabbed="">Picture 4</div>

Example 2: Creating a Drop Spot

Album 1
Album 2

Code


<div role="treeitem" aria-dropeffect="move">Album 1</div>
<div role="treeitem" aria-dropeffect="move">Album 2</div>

Example 3: Alternative

Picture 1
Picture 2
Albums:

Code


<input type="checkbox" id="picture1" aria-label="Select to move Picture 1">Picture 1 
<input type="checkbox" id="picture2" aria-label="Select to move Picture 2">Picture 2 
Albums:
<select aria-label="Select an Album in which to move the Pictures">
<option>Album 1</option>
<option>Album 2</option>
</select>
<input type="submit" value="Move Pictures">

Standards:

ARIA LABEL, LABELLEDBY and DESCRIBEDBY

Tuesday, May 17th, 2011

ARIA DescribedBy (aria-describedby), aria-labelledby and aria-label are all very similar and all can be used to communicate with the screen reader.

Example 1:

Aria Label
Aria Labelled By
Aria Described By

Code


<table>
<tr><td><span id="my_desc1">Aria Label</span></td><td><button aria-label="Aria Label">submit</button></td></tr>
<tr><td><span id="my_desc2">Aria Labelled By</span></td><td><button aria-labelledby="my_desc2">submit</button></td></tr>
<tr><td><span id="my_desc3">Aria Described By</span></td><td><button aria-describedby="my_desc3">submit</button></td></tr>
</table>

Standards:

ARIA DescribedBy

Tuesday, May 17th, 2011

ARIA DescribedBy (aria-describedby) is used to associate descriptive information to HTML elements. In doing so, the browser makes it available to assistive technology through the MSAA Description value. The aria-describedby points to a unique id or list of unique ids. It is very useful when providing a additional descriptions, and as an example, can point to a paragraph or a span encompassing a group of paragraphs. aria-describedby is very similiar to aria-labelledby

At the time of writing this document, I am not sure how well it is supported. Try the following example and find out.

Example 1:

Aria Described By

Code:


<span id="my_desc3">Aria Described By</span></td><td><button aria-describedby="my_desc3">submit</button><br />

Example 2:

Rublev's Trinity

This is a long paragraph containing the long description for the image.

It includes as much description as you need.

Code:


<img src="http://www.donaldevans.com/images/trinity.jpg" 
    aria-labelledby="long_alt" 
    aria-describedby="long_alt2"  
    alt="Rublev's Trinity" />
<div id="long_alt">
<p>
This is a long paragraph containing the long description for the image.
</p>
</div>
<div id="long_alt2">
<p>
It includes as much description as you need.
</p>
</div>

Standards:

ARIA LabelledBy

Monday, May 16th, 2011

ARIA LabelledBy (aria-labelledby) is used to associate descriptive information to HTML elements. In doing so, the browser makes it available to assistive technology through the MSAA Name value. The aria-labelledby points to a unique id or list of unique ids. It is very useful when providing a “label” for an input field, although it can be used to label almost anything.

The HTML label tag has traditionally been used to associate a text label with an HTML input tag; although, best practice is to provide either a label or a title attribute on the input field itself. And it is still recommended to accomodate older browsers and assistive technology.

Example 1:

Provide the info as it appears on your credit card:




Code


<div id="LabelInstructions">
Provide the info as it appears on your credit card:
</div>
<input type=text id="firstname" aria-labelledby="LabelInstructions FirstName">
<span id="FirstName"><label for="firstname">First Name</label></span>
<input type=text id="lastname" aria-labelledby="LabelInstructions LastName">
<span id="LastName"><label for="lastname">Last Name</label></span>

Example 2:

Search the Category

Code


<button id="searchbutton" aria-labelledby="searchlabel">
Search
</button>
<span id="searchlabel"> Search the Category </span>
</pre>
<p>

Standards:

ARIA Label

Monday, May 16th, 2011

ARIA Label (aria-label), is used to create a label from a text string. It takes the form of aria-label="text string". This could be useful when there is no on screen text to use for a label.

Example 1:


<button aria-label="Aria Label">submit</button>

Example 2:


<input type="text" aria-label="Aria Label">

Example 3:

Code:


<button aria-label="ARIA Label"><img src="http://www.donaldevans.com/images/trinity.jpg" alt="Rublev's Trinity" /></button>

Standards: