Theresa O’Connor

ARIA’s role (class 2: Electric Boogaloo)

This blog post has been sitting around in my drafts folder for a long, long time, and is about a debate long settled. While spring-cleaning my drafts, I thought that it might still shed some light for people on the weird naming difference between role="" and the other ARIA attributes, so there you go.

Suppose you’re a web author, or maybe a widget developer, and you’re reading about how to use WAI-ARIA in HTML. You might find it odd that all but one of ARIA’s attributes look like aria-foo="". The exception is role="". So what’s the deal with that?

Several years ago, the (now defunct) XHTML2 Working Group decided that XHTML2 needed a way for authors to imbue elements with custom semantics, to layer additional meaning onto elements. But HTML-family languages already had such a mechanism: class="". Web authors have been using class="" to enhance their markup with additional semantics for years and years. The practice of using semantic class names has been widespread in the web authoring community since at least 2002. The W3C itself has encouraged authors to use class="" with semantics in mind since 2004. The whole Microformats effort is built around this.

Anyway, the XHTML2 WG decided to invent their own class="" attribute, which they called role="". They then back-ported role="" into XHTML 1. This is the entirely-redundant-with-class="" XHTML Role Attribute Module.

Well, role=""’s been about as successful as XHTML2 itself, which is to say, not successful at all. But when WAI started to work on ARIA, XHTML2 and all that were still going concerns, so they tried to be forward-looking by attaching ARIA semantics to elements with the XHTML Role Module. (They also decided to do some other things that didn’t work out, like their since-reversed decision to use XML Namespaces for the other ARIA attributes.)

The concerted, successful effort to integrate ARIA into HTML5 and SVG revealed a lot of these issues, and ARIA is much improved as a result. aria:foo="" became aria-foo="", and ARIA stopped using the XHTML Role Module and CURIEs. But at that point, given already-deployed web content with ARIA in it, it was considered too costly to bring role="" into alignment, name-wise, with the rest of the ARIA attributes. So role="", though restricted to its ARIA use-case, remains this weird echo of the abandoned XHTML2 effort.