Using Microdata's 'itemprop' attribute on non-text elements

大兔子大兔子 提交于 2020-01-06 00:39:44

问题


I have a following piece of HTML with some Schema.org Microdata added:

<section class="feature" itemprop="description">
    <div class="measure">
      <p>Lorem ipsum etc...</p>
      <p>Lorem ipsum etc...</p>

      <figure class="polaroid product">
        <img src="dry-aged-beef-horizontal.jpg", alt="Dry Aged Beef", itemprop="image" />
        <figcaption>Dry Aged Beef</figcaption>
      </figure>
    </div>
  </section>

Is it all right to use the itemprop attribute on an element that isn't itself a text node (like section above), but contains child elements that are?

Looking at the official Schema.org examples one could become suspicious that only text elements can be tagged with Microdata attributes:

<span itemprop="description">0.7 cubic feet countertop microwave.   Has six preset cooking categories and convenience features like   Add-A-Minute and Child Lock.</span>

Also, my product description consists of more paragraphs than one, so again setting the itemprop tag on a parent element makes all the sense. Is this correct Microdata/Schema.org though?


回答1:


Microdata (W3C Note) defines that the property value is, in the general case (which applies in your example):

[…] the element's textContent.

So yes, your usage is fine.

(Of course this means that "Dry Aged Beef" will also be part of the description value.)



来源:https://stackoverflow.com/questions/24241779/using-microdatas-itemprop-attribute-on-non-text-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!