ARIA - why it only validates in HTML 5
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.
- The W3 specifications of HTML 4.01 (1999), XHTML 1.0 (2000 revised 2002) and XHTML 1.1 (2001 revised 2010) all pre-date ARIA (2011) so weren’t aware of ARIA at the time of writing.
- The W3 specifications all contain DTDs that are marked as normative (i.e. the DTDs are a prescriptive part of the specification, so cannot be changed and aren’t open to interpretation).
- This means that ARIA can’t be added to these DTDs without revising the underlying specifications
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:
- XHTML 1.1 with ARIA https://www.w3.org/TR/wai-aria/appendices#xhtml_dtd
- HTML 4.01 with ARIA https://www.w3.org/TR/wai-aria/appendices#html_dtd
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 &NBSP; 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.
First posted Mar 2012, updated Jul 2015