0

Is the "content" attribute valid for span tag? If so is it a good practice? I'll be applying microdata (schema.org) on my site pages.

I want to add microdata on 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 a div with class "hidden" there because the model and id shouldn't be displayed on the page.

I want to minify the code by doing this:

<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" />&nbsp;</span>
        <span itemprop="model" content="ACOS5T-B2-SCZ" />&nbsp;</span>
    </a>    
</span>

I can use meta instead of span so that the content is not visible. But I think it won't be a good practice since I'll be having a lot of items. What can you suggest? Thanks.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52

2 Answers2

0

I tested your updated code with Google's richsnippets test tool and it works fine with the content attribute on the span.

However, this isn't good practice since there is no content inside the last 2 spans anyway. It is perfectly appropriate in this case to use metas.

<meta itemprop="productid" content="286">
<meta itemprop="model" content="ACOS5T-B2-SCZ">
Nelu
  • 16,644
  • 10
  • 80
  • 88
  • say i have 15 items, there will be lot of _meta_ tags, i think google would consider it as inappropriate and overused. – user3909562 Aug 06 '14 at 03:09
0

No, it’s not valid.

Neither HTML5 nor Microdata define a content attribute for span. (RDFa does, but you are not using it.)

If you want to markup content with Microdata that should not be visible, either

  • use usual HTML and hide it with CSS, or
  • use link elements (for URIs) and meta elements (for anything else); both elements are allowed in the body, and typically hidden by default browser stylesheets.

I’d prefer the latter variant (meta/link), but it’s not possible everytime (e.g., if you need to add new items with itemscope).

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • i can wrap the new _itemscope_ in a _span_ tag, but i think, since there will be a lot of products, using _meta_ will be considered by google as inapropriate? – user3909562 Aug 06 '14 at 03:07
  • @user3909562: Of course it would be better to mark up visible content, but as you don’t want to do that, you have the mentioned options. Note that discussing such SEO-related rules from specific consumers (like Google) is off-topic on Stack Overflow; but it’s safe to assume that hiding content via CSS (instead of using `meta`/`link`) would be more problematic than using the appropriate mechanism specified in Microdata and also mentioned on Schema.org: using `meta`/`link` for invisible content. – unor Aug 06 '14 at 08:18
  • yes, i think using meta would be better. Thanks @unor – user3909562 Aug 07 '14 at 02:17