在非文本元素上使用Microdata的'itemprop'属性 [英] Using Microdata's 'itemprop' attribute on non-text elements

查看:118
本文介绍了在非文本元素上使用Microdata的'itemprop'属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

; section class =featureitemprop =description>
< div class =measure>
< p> Lorem ipsum等......< / p>
< p> Lorem ipsum等......< / p>

< figure class =宝丽来产品>
< img src =dry-aged-beef-horizo​​ntal.jpg,alt =干老牛肉,itemprop =image/>
< figcaption>干A牛肉< / figcaption>
< / figure>
< / div>
< / section>

是否可以使用 itemprop 属性本身不是文本节点的元素(例如上面的),但包含的子元素是?



查看官方Schema.org示例

 < span itemprop =>可能会变得怀疑只有文本元素可以用Microdata属性标记: 描述> 0.7立方英尺的台面微波。有6种预设烹饪类别和方便功能,如添加分钟和儿童锁。< / span> 

此外,我的产品说明由多于一个段落组成,所以再次设置父元素上的itemprop 标签具有所有意义。这是正确的Microdata / Schema.org虽然?

解决方案

Microdata(W3C注)定义该属性值在一般情况下(在您的示例中适用):


[元素的 textContent




所以是的,你的用法很好。



(当然这意味着干老牛肉也会成为零食 description 值。)


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?

解决方案

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.)

这篇关于在非文本元素上使用Microdata的'itemprop'属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆