Friday, January 20, 2012

HTML5 microdata markup validation

HTML5 introduces the microdata concept to web page design: HTML elements can semantically be annotated by using item attributes such as itemscope, itemtype and itemprop. Typically, I am using the W3C Markup Validation Service at validator.w3.org to test my HTML5 pages and have experienced good results in checking markup validity. The good news is the bad news: the W3C validator is rather strict and—unfortunately—is too picky when it comes to microdata. For example, it reports errors detected in the shown code snippet, although this code has correct HTML5 syntax.


The code example illustrates annotation of a short text about a chemical substance. This code employs microdata (property/value pairs) according to the vocabulary defined at www.axeleratio.com/voc/chemid. The W3C validator complains about the item attributes, declaring that their use is not allowed on the selected elements at this point. In contrast, the (X)HTML5 Validator at html5.validator.nu declares that this code is valid HTML5, after submitting a page containing this code snippet. The NU Markup Validation Service at qa-dev.w3.org:8888/html5 came up with the same result. The latter validator—according to the statement on its site—checks the markup validity like the current W3C validation service, but instead uses the backend of the Validator.nu engine, which provides non-DTD-based validation support for a number of markup languages. Currently, this latter service is a potentially unstable pilot version, provided for demonstration and testing purposes only.

Suggested sites for microdata digging: 
W3C: www.w3.org/TR/microdata/
Wikipedia: en.wikipedia.org/wiki/Microdata_%28HTML%29
Tutorials Point: www.tutorialspoint.com/html5/html5_microdata.htm
Google: support.google.com/webmasters/bin/answer.py?hl=en&answer=176035