Validating WAI-ARIA in HTML and XHTML
WAI-ARIA has great potential to help developers make the Web more accessible to people with disabilities, especially those who are vision impaired or cannot use a mouse.
There is currently a problem with adding WAI-ARIA attributes to your HTML or XHTML markup though: the attributes are not defined in the DTDs for HTML or XHTML and will cause validation errors.
Since WAI-ARIA improves accessibility I could actually live with having some validation errors in my HTML. However, having to manually filter out certain errors to catch the real errors really reduces the value of validation as a quality assurance tool.
Like Steve Faulkner says in How Can I Validate (X)HTML + ARIA?, what I want validation to do is check that:
- any WAI-ARIA attributes and attribute values I use are valid
- the rest of my markup is valid HTML or XHTML
Custom DTDs to the rescue?
Steve has had some success while experimenting with custom DTDs that contain all WAI-ARIA attributes and their allowed values. The main drawback is that you need to manually validate each page. It’s doable, but compared to letting the HTML Validator Extension for Firefox automatically validate each page you open it requires a lot more work (and having a live connection to the Internet).
I replaced the DTDs that the HTML Validator Extension uses with Steve’s custom DTDs and it sort of works. Unfortunately I ran into the problem with the DTD containing too many attributes and attribute values that Steve describes in his post, making it more or less unusable since you have to dismiss almost 60 warning dialogs before the validation results are displayed. The extension will probably need to be updated to fix that.
Update: Steve emailed me with a fix for the HTML Validator extension problem. Open the /sgml-lib/sgml.dcl file in the extension’s folder and change the ATTCNT value to 300 and the errors will be gone.
If you want to try this yourself you can grab the latest versions of the DTDs from http://svn.codetalks.org/repos/trunk/tools/ARIA-DTDs/.
Another option for us Mac users is Validator S.A.C., a stand-alone application (which removes the need for an Internet connection to validate documents). A beta version that uses the DTDs that Steve added WAI-ARIA attributes to is available – find more details in W3C Validator for MAC OSX with Experimental WAI-ARIA Support.
Hoping for improved W3C support
So, while there are ways of checking the validity of markup that uses WAI-ARIA attributes, it is currently more trouble than I would like it to be.
I hope the W3C Markup Validator is updated to enable validating WAI-ARIA soon, which doesn’t look that far-fetched if you read a thread on W3C’s Markup Validator mailing list.