This proposal defines proper usage of ARIA markup for authors and ARIA markup processing for user agents for both (X)HTML and other vocabularies.
role
attributes
This spec assumes that HTML elements are in the
http://www.w3.org/1999/xhtml
namespace, as required by HTML5.
What authors are allowed to do should probably be constrained, and UAs should perhaps ignore some roles or states in certain cases.
All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC2119. For readability, these words do not appear in all uppercase letters in this specification. [RFC2119]
Implementations must support some version of DOM Core, because this specification is defined in terms of the DOM. [DOM3CORE]
role
attributesAuthors may specify a role
attribute in no namespace on any
element in the http://www.w3.org/1999/xhtml
or
http://www.w3.org/2000/svg
namespace.
The value of these attributes must be an ordered set of space-separated tokens where each token must be a valid role token. For accessibility-related roles, the first supported role will be used; subsequent roles act as fallback roles. [HTML5]
A valid role token is one of the following:
A role as defined in WAI-ARIA Roles or XHTML Role Attribute Module. [ROLES] [MODULE]
The eight characters wairole:
followed by a role as
defined in WAI-ARIA Roles, if there is a namespace declaration in scope
that binds the prefix wairole
to the
http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#
namespace. [ROLES] [XMLNS]
A CURIE whose prefix is not omitted and is not wairole
,
if there is a namespace declaration in scope that defines the prefix and
that prefix is not bound to the
http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#
or
http://www.w3.org/1999/xhtml
namespace. [CURIE] [XMLNS]
The "default namespace" is always
http://www.w3.org/1999/xhtml
, regardless of any actual
namespace declarations.
Thus the roles defined in WAI-ARIA Roles are effectively
duplicated in the http://www.w3.org/1999/xhtml
namespace.
The wairole
prefix is thus fixed to the
http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#
namespace,
just like the xml
prefix is fixed to the
http://www.w3.org/XML/1998/namespace
namespace in XML.
However, unlike the xml
prefix, the wairole
prefix has to be declared before it is used according to this
specification.
Since HTML doesn't do namespaces, the only allowed way to express roles declaratively in HTML is by using the unprefixed syntax, as in the following example:
<div role="checkbox" tabindex="0"></div>
In XHTML and SVG, the following are allowed:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wairole="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#"> ... <div role="checkbox" tabindex="0"/> <div role="wairole:checkbox" tabindex="0"/> <svg xmlns="http://www.w3.org/2000/svg"> <circle role="checkbox" focusable="true"/> <circle role="wairole:checkbox" focusable="true"/> ...
UAs must process the value of a role
attribute in no
namespace that is part of an element in the
http://www.w3.org/1999/xhtml
or
http://www.w3.org/2000/svg
namespace as described below.
The following algorithm will return the role identifier:
Let tokens be the result of splitting the string on spaces. [HTML5]
For each token in tokens:
If token is a role as defined in WAI-ARIA Roles, then return token and abort these steps. [ROLES]
If token is the eight characters wairole:
followed by a role as defined in WAI-ARIA Roles, then return the
characters from the ninth character up to the end of token
and abort these steps. [ROLES]
If token is a supported custom role that is supposed to map to an accessibility API, then return token and abort these steps.
It is expected that AT vendors would introduce such custom roles.
Return the empty string.
UAs must expose the entire value of the attribute as a string to the AT
using accessibility API specific methods, unless the role identifier is presentation
and the element on which the attribute is specified is not focusable. UAs
should also map the role identifier to an
accessibility API specific role, if there is one. [MAPPING]
Find out what that actually means and define it.
When the role identifier is the empty string, it won't map to anything.
Authors may specify a state or property propertyname (as
defined in WAI-ARIA States and Properties) by specifying an attribute
aria-propertyname
in no namespace on an element in
the http://www.w3.org/1999/xhtml
namespace, or by specifying
an attribute propertyname
in the
http://www.w3.org/2005/07/aaa
namespace on an element in any
namespace, unless that element is in the
http://www.w3.org/1999/xhtml
namespace and it has an
aria-propertyname
attribute in no namespace
specified. [STATES]
The value of these attributes must be one of the allowed values of the state or property propertyname (as defined in WAI-ARIA States and Properties). [STATES]
Since HTML doesn't do namespaces, the only way to express states or
properties declaratively in HTML is by using
aria-propertyname
attributes, as in the following
example:
<div aria-hidden="true">...</div>
In XHTML and SVG, the following are allowed:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:aaa="http://www.w3.org/2005/07/aaa"> ... <div aria-hidden="true">...</div> <div aaa:hidden="true">...</div> <svg xmlns="http://www.w3.org/2000/svg"> <g aaa:hidden="true">...</g>
UAs must process an aria-propertyname
attribute
in no namespace that is part of an element in the
http://www.w3.org/1999/xhtml
namespace as described below,
unless that element has a propertyname
attribute
in the http://www.w3.org/2005/07/aaa
namespace specified.
UAs must process a propertyname
attribute in the
http://www.w3.org/2005/07/aaa
namespace that is part of an
element in any namespace as described below.
Map propertyname to an accessibility API specific attribute, if any, and pass along the value. [MAPPING]
[MODULE] http://www.w3.org/TR/2007/WD-xhtml-role-20071004/ [CURIE] http://www.w3.org/TR/2007/WD-xhtml-role-20071004/#sec_3.1.1. (for now) [ROLES] http://www.w3.org/WAI/PF/Group/GUI/ (Member-only) or http://www.w3.org/TR/2007/WD-aria-role-20070601/ [STATES] http://www.w3.org/WAI/PF/Group/adaptable/ (Member-only) or http://www.w3.org/TR/2007/WD-aria-state-20070601/ [MAPPING] http://developer.mozilla.org/en/docs/ARIA_to_API_mapping [XMLNS] http://www.w3.org/TR/2006/REC-xml-names-20060816/ [HTML5] http://www.whatwg.org/specs/web-apps/current-work/multipage/ [DOM3Core] http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/ [RFC2119] http://www.ietf.org/rfc/rfc2119.txt
Thanks to Al Gilman, Anne van Kesteren, Dave Raggett, Doug Schepers, Henri Sivonen, Maciej Stachowiak, Mark Birbeck, and Richard Schwerdtfeger for their useful and substantial comments.