Itemscope and itemprop at same level

梦想的初衷 提交于 2019-12-01 16:38:40

问题


I have a link that looks like this:

<a href="//href" itemscope itemtype="http://schema.org/Product">
    <img src="src" itemprop="image">
</a>

I'd like to put itemprop="url" in the <a> tag, but it contains the itemscope for that product. Can I put that at the same level as itemtype=?

Or, do I either need to wrap the whole thing in a div to make it work, or use a <meta> tag for the itemprop="url" microdata? Thanks!


回答1:


You can have itemprop and itemscope on the same element, but it will mean something different.

In this example, a Product item has the url property:

<div itemscope itemtype="http://schema.org/Product">
  <a href="//href" itemprop="url">…</a>
</div>

In this example, some other item has the url property, and its value is a Product item:

<a href="//href" itemprop="url" itemscope itemtype="http://schema.org/Product">…</a>

(Note for the the latter case: the url value is the Product item, not the URL in the href attribute! So this probably doesn’t make sense for the url property.)




回答2:


No you don't need another wrapper to do that. You can specify itemprop="url" to the a tag.

This technique called "nested scope"

More about this is available at section 2.2 The basic syntax of this link http://www.w3.org/TR/2011/WD-microdata-20110525/



来源:https://stackoverflow.com/questions/21877480/itemscope-and-itemprop-at-same-level

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