Is the "content" attribute valid for the <span>> tag, if that's good practice?
Is the "content" attribute valid for the tag span
? If so, is it good practice? I will be using microdata (schema.org) in my site pages.
I want to add microdata to some elements of my page.
This is my current code:
<span itemscope itemtype="http://schema.org/Product">
<a itemprop="url" class="list-items" href="/product/286/cryptomate64-usb-cryptographic-token/" title="CryptoMate64 USB Cryptographic Token">
<span itemprop="name">CryptoMate64 USB Cryptographic Token</span>
<span class="hidden">
<span itemprop="productid"/>286</span>
<span itemprop="model" content="ACOS5T-B2-SCZ" />ACOS5T-B2-SCZ</span>
</span>
</a>
</span>
As you can see, I have it div
with the "hidden" class because the model and id should not be displayed on the page.
I want to reduce the code by doing the following:
<span itemscope itemtype="http://schema.org/Product">
<a itemprop="url" class="list-items" href="/product/286/cryptomate64-usb-cryptographic-token/" title="CryptoMate64 USB Cryptographic Token">
<span itemprop="name">CryptoMate64 USB Cryptographic Token</span>
<span itemprop="productid" content="286" /> </span>
<span itemprop="model" content="ACOS5T-B2-SCZ" /> </span>
</a>
</span>
I can use meta
instead span
so that the content is not visible. But I think it won't be good practice as I will have a lot of items. What can you offer? Thank.
source to share
I checked your updated code with google richsnippets testing tool and it works fine with attribute content
on span
.
However, this is not a good practice as there is no content inside the last two intervals anyway. In this case, it makes perfect sense to use metas .
<meta itemprop="productid" content="286">
<meta itemprop="model" content="ACOS5T-B2-SCZ">
source to share
No, its invalid .
Neither HTML5 nor Microdata define an attribute content
for span
. ( RDFa does , but you don't use it.)
If you want to mark up content with Microdata that shouldn't be visible,
- use normal HTML and hide it with CSS, or
- use elements
link
(for URI) andmeta
(for anything else); both are allowed inbody
and are usually hidden by default in browser style sheets.
Id prefers the last option ( meta
/ link
), but it is not possible every time (for example, if you need to add new elements with itemscope
).
source to share