Flag of the United Kingdom
Andreas Rejbrands webbplats

Aktuellt

Web design: Non-conforming examples at schema.org

When investing the http://schema.org/Book vocabulary, I also had a look at the examples given on that web page. And it turns out they are non-conforming.

Recall that I wrote <meta itemprop="inLanguage" content="en" />English in my book list sample item. The text displayed to the user is ‘English’ and the microdata value, seen by robots, is ‘en’. This difference is necessary since ‘English’ is human-readable, while the microdata field should be a BCP 47 code. As a second example, recall that I wrote <span itemprop="bookFormat">Hardcover</span>. According to the vocabulary, the bookFormat property must be Hardcover, Paperback, or EBook. Hence, if I would like to present a book’s format as ‘PDF’ to the user, I could write <meta itemprop="bookFormat" content="EBook" />PDF.

As demonstrated above, the microdata specification allows the use of <meta> elements as a generic way of specifying user-invisible microdata properties (often next to a user-friendly presentation). [In some cases, there are more specific ways to achieve this, like dates and times, e.g. <time itemprop="something" datetime="2014-11-29">November 29, 2014</time>.]

The problem with the examples at schema.org is that they use a non-conforming way of achieving this (instead of the standard <meta> way). For instance, the following three lines can currently be seen at the Book page at schema.org:

<!-- Wrong! -->
<span itemprop="price" content="6.99">$6.99</span>
<span itemprop="inLanguage" content="en">English-language</span>
<span itemprop="name" content="Tolkien, J. R. R. (John Ronald Reuel)">
J. R. R. Tolkien</span>

Clearly, they use <span> elements with content attributes. This is non-conforming. Neither the HTML5 specification nor the microdata specification even mentions this attribute! (Much less does the microdata specification take this attribute into account when determining the value of a property.) Se this StackOverflow question for more information.

Update (2014-11-29 19:45:57): Of course, a different general way of providing a machine-readable form (possibly a microdata value) of some text is to use the <data> element, as in <data itemprop="inLanguage" value="en">English</data>. This also connects the machine-readable form to the human-friendly form.


Visa alla tidigare notiser.

Visa enbart de senaste notiserna.