1

How to write this Microdata code

<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    <span itemprop="ratingValue">4.6</span> (
    <span itemprop="ratingCount">8864</span> ratings )
  </div>

  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    Price: $<span itemprop="price">1.00</span>
    <meta itemprop="priceCurrency" content="USD" />
  </div>

as <link …> or <meta …>? I do not have HTML tag in my page.

unor
  • 92,415
  • 26
  • 211
  • 360
partiz
  • 1,206
  • 2
  • 13
  • 34

1 Answers1

4

If the value is a URI, use link. Otherwise, use meta.

So <span itemprop="ratingValue">4.6</span> becomes <meta itemprop="ratingValue" content="4.6" /> etc.

If it’s just about having no visible content, you could keep using the parent div elements, e.g.:

<div itemscope> <!-- you can/should give it an itemtype -->

  <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    <meta itemprop="ratingValue" content="4.6" />
    <meta itemprop="ratingCount" content="8864" />
  </div>

  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <meta itemprop="price" content="1.00" />
    <meta itemprop="priceCurrency" content="USD" />
  </div>

</div>

If you also want to omit these div elements, you’d have to use the itemref attribute, because you can’t nest elements under link/meta. And because meta elements used for Microdata require the itemprop attribute, you have to use one parent element (e.g., div, body, html) to specify an itemscope:

<body itemscope> <!-- you can/should give it an itemtype -->

  <meta itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" content="" itemref="my-rv my-rc">
  <meta itemprop="ratingValue" content="4.6" id="my-rv" />
  <meta itemprop="ratingCount" content="8864" id="my-rc" />

</body>

Having said that, if you generally don’t want to markup your existing/visible content, you might want to use JSON-LD instead of Microdata or RDFa.

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360