This proposal defines proper usage of ARIA markup for authors and ARIA markup processing for user agents for both (X)HTML and other vocabularies.
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
namespace.
Authors may specify a role
attribute in the http://www.w3.org/1999/xhtml
namespace on any element that is not in the http://www.w3.org/1999/xhtml
or http://www.w3.org/2002/06/xhtml2/
namespace.
The value of these attributes must be an ordered set of space-separated tokens where each token must be a valid role token. 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 prefixed name whose prefix 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#
namespace. [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"></div>
In XHTML, the following is allowed:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wairole="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#"> ... <div role="checkbox"/> <div role="wairole:checkbox"/>
In other vocabularies such as SVG, the namespaced role
attribute has to be used:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml"> ... <circle h:role="checkbox" .../>
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
namespace as described below.
UAs must process the value of a role
attribute in the http://www.w3.org/1999/xhtml
namespace that is part of an element that is not in the http://www.w3.org/1999/xhtml
or http://www.w3.org/2002/06/xhtml2/
namespace as described below.
No other attributes are to be processed this way — in particular not any role
attributes in the http://www.w3.org/TR/xhtml2
namespace.
XHTML 2.0 defines a role
attribute in no namespace on elements in the http://www.w3.org/2002/06/xhtml2/
namespace — how that attribute is to be processed is defined in the XHTML 2.0 specification and does not conflict with this specification in any way.
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 the token is a role (as defined in WAI-ARIA Roles), then return the token and abort these steps.
If the 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 the token and abort these steps.
If the token is a supported custom role that is supposed to map to an accessibility API, then return the 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 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, 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>
In other vocabularies such as SVG, the namespaced attribute has to be used:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:aaa="http://www.w3.org/2005/07/aaa"> ... <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.
No other attributes are to be processed in this way — in particular not propertyname
attributes in no namespace on elements in the http://www.w3.org/1999/xhtml
namespace (as in e.g. <div hidden="true"/>
).
Map propertyname to an accessibility API specific attribute, if any, and pass along the value. [MAPPING]
[MODULE] http://www.w3.org/MarkUp/2007/ED-xhtml-role-20070606/Overview.html [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, Henri Sivonen, Maciej Stachowiak, and Richard Schwerdtfeger for their useful and substantial comments.