ARIA - why it only validates in HTML 5

Posted by Mark Rogers on Jul 7, 2015 | 

Accessibility

The W3 ARIA recommendation specifies new HTML attributes (like ARIA-DESCRIBEDBY and ROLE) to help screen readers identify relationships between elements. These new attributes tell screen readers about relationships that can’t be derived from existing HTML semantics, and usually only obvious from the position of items on screen (e.g. a paragraph of help text next to a form field).

Most people who’ve tried adding ARIA attributes to pages with HTML 4 and XHTML DOCTYPES have noticed that documents don’t validate.

Why is this - are the validators all broken? Unfortunately, the problem is worse than this.

What’s the problem?

The validation rules for old versions of HTML used by validator.w3.org and the other validators out there (including SortSite) use a machine-readable description of HTML called a Document Type Definition (DTD). Prior to HTML 5, each version of HTML and XHTML was specified by a DTD describing which element and attribute names are allowed in a document.

Here’s why:

In retrospect, including DTDs as part of the normative specifications of HTML and XHTML was probably a mistake by the W3 working groups, and one that’s been avoided in HTML 5 which doesn’t use DTDs.

Don’t expect the W3 to add ARIA to DTDs for old versions of HTML any time soon. Even fixing obvious bugs in the DTDs takes a very long time, because it requires a specification revision. The USEMAP bug in the XHTML 1.1 DTD took 8 years to fix - prior to the 2010 revision of XHTML 1.1 you had to choose between working image maps or valid code.

Does HTML 5 fix this?

Yes, migrating to HTML 5 allows you to use ARIA as well as the new HTML form and sectioning elements. If you can’t use HTML 5 then your options are more limited. The ARIA working group are aware of the problem, and have produced two unofficial DTDs that do allow ARIA to validate:

These DTDs are both available in validator.w3.org and SortSite 4.6 onwards, but as the ARIA recommendation notes, using the DOCTYPEs for either of these DTDs cause significant problems in browsers (such as character entities like   not working correctly).

In SortSite the other option is to to selectively ignore validation errors for aria- prefixed attributes using Ignore Rule menu command. To do this right click on the Rule Options link next to an error for an aria feature, and choose Ignore Rule.

Tags:

First posted Mar 2012, updated Jul 2015