According to Google’s documentation about the Product Rich Snippet, when I want to mark product’s availability in my shop, I should do the following (using Microdata):
<span itemprop="availability" content="in_stock">In stock! Order now!</span>
And I do similar:
<p class="centered" itemprop="availability" content="in_stock">Produkt dostępny</p>
Unfortunately the W3C validator reports an error on this:
Line 569, Column 73: Attribute
content
not allowed on elementp
at this point.
So, what is wrong with my code or with Google?
EDIT: I also have warnings:
RDFa Core attribute
content
is not allowed on thep
element in HTML5 + RDFa 1.1 Lite documents. Consider checking against the HTML5 + RDFa 1.1 schema instead.
But if I understand specs correctly, HTML5 implies RDFa 1.1, not 1.1 Lite? My DOCTYPE is <!DOCTYPE HTML>
.
EDIT2: I got the solution now
Despite my code in question not being correct HTML5 code, it was correctly recognized by Google’s tool for testing Rich Snippets. It did not satisfy me, so I decided that if content
attribute was only allowed on <meta>
tags, let’s go with <meta>
:
<p class="centered">Produkt dostępny</p>
<meta itemprop="availability" content="in_stock"/>
This way the code is:
- unambiguous - the
meta
element is a child of theitemscope
element, - accepted by HTML5 validation tool,
- still recognized properly by Google’s tool.
<p>
tag to a<span>
?