How do I have an itemprop nested in one itemscope actually be applied to a different itemscope?

前端 未结 1 1510
终归单人心
终归单人心 2020-12-11 09:51

TL;DR --> I want an itemprop nested in one itemscope to actually be applied to a different itemscope. How do I do that?

Here\'s a a gist of the co

相关标签:
1条回答
  • 2020-12-11 10:19

    Assuming you mean you want it only attached to the Product, as per your penultimate paragraph, and not only attached the aggregateRating as per per your last paragraph, then the best I can come up is

    <div itemscope itemtype="http://schema.org/Product" itemref="productMicrodata">
      <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
        <span itemprop="ratingValue">79</span>
        <h1 itemscope><span itemprop="name" id="productMicrodata">Someproductsoandso</span></h1>
        <span itemprop="reviewCount">830</span>
      </div>
    </div>
    

    The itemscope on the h1 hides the h1's children from the aggregateRating item, so the name property will only be attached to the Product item via the productMicrodata itemref. It does however, create a third item which has no type.

    0 讨论(0)
提交回复
热议问题