首页
学习
活动
专区
工具
TVP
发布

itemtype(属性) | itemtype (attribute)

全局属性itemtype指定将用于定义itemprop数据结构中的(项目属性)的词汇表的URL 。itemscope用于设置数据结构中设置的词汇itemtype将处于活动状态的范围。

谷歌和其他主要的搜索引擎支持schema.org词汇表的结构化数据。这个词汇表定义了一组标准的类型名称和属性名称。例如,MusicEvent表示音乐会表演,startDate以及location指定音乐会关键细节的属性。在这种情况下,MusicEvent itemtype,与startDateMusicEvent定义的位置将被itempropURL使用。

注意:关于itemtype属性的更多信息可以在http://schema.org/Thing找到

  • 项目类型属性必须有一个值是一组无序独特标记,其区分大小写的,各是一个有效的和绝对的URL,并且所有定义为使用相同的词汇。该属性的值必须至少有一个令牌。
  • 项目类型必须全都是适用规范中定义的类型(如schema.org),并且必须全部定义为使用相同的词汇表。
  • itemtype属性只能在指定了itemscope属性的元素上指定。
  • itemid属性只能在同时指定了itemscope属性和itemtype属性的元素上指定。它们只能在具有itemscope属性的元素上指定,其itemtype属性指定不支持项目的全局标识符的词汇表,如词汇表规范所定义。
  • 全局标识符的确切含义由词汇表的规范决定。留下这样的规范来定义是否允许相同全局标识符(无论在同一页面还是不同页面上)的多个项目存在,以及该词汇表的哪些处理规则是关于处理多个项目的情况相同的ID。

简单的例子

HTML

<div itemscope itemtype="http://schema.org/Product">
  <span itemprop="brand">ACME</span>
  <span itemprop="name">Executive Anvil</span>
</div>

结构化数据

itemscope

itemtype

schema.org Product

itemprop

name

Executive Anvil

itemprop

brand Thing

itemprop

name

ACME

样例

HTML

<div itemscope itemtype="http://schema.org/Product">
  <span itemprop="brand">ACME<br></span>
  <span itemprop="name">Executive Anvil<br></span>
  <img itemprop="image" src="https://pixabay.com/static/uploads/photo/2015/09/05/18/15/suitcase-924605_960_720.png" width="50" height="50" alt="Executive Anvil logo" /><br>
  
<span itemprop="description">Sleeker than ACME's Classic Anvil, the
    Executive Anvil is perfect for the business traveler
    looking for something to drop from a height.
  <br>
</span>

  Product #: <span itemprop="mpn">925872<br></span>
  <span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    Rating: <span itemprop="ratingValue">4.4</span> stars, based on <span itemprop="reviewCount">89
      </span> reviews
  </span><p>
  
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    Regular price: $179.99<br>
    <meta itemprop="priceCurrency" content="USD" />
    <span itemprop="price">Sale price: $119.99<br></span>
    (Sale ends <time itemprop="priceValidUntil" datetime="2020-11-05">
      5 November!</time>)<br>
    Available from: <span itemprop="seller" itemscope itemtype="http://schema.org/Organization">
                      <span itemprop="name">Executive Objects<br></span>
                    </span>
    Condition: <link itemprop="itemCondition" href="http://schema.org/UsedCondition"/>Previously owned,
      in excellent condition<br>
    <link itemprop="availability" href="http://schema.org/InStock"/>In stock! Order now!
</span>

</div>

结果

HTML

结构化数据

itemscope

itemtype

itemprop

name

Executive Anvil

itemprop

image

itemprop

description

Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.

itemprop

mpn

925872

itemprop

brand Thing

itemprop

name

ACME

itemscope

itempropitemtype

aggregateRatingAggregateRating

itemprop

ratingValue

4.4

itemprop

reviewCount

89

itemprop

offers Offer

itemprop

priceCurrency

USD

itemprop

price

119.99

itemprop

priceValidUntil

2020-11-05

itemprop

itemCondition

itemprop

availability

itemscope

itempropitemtype

seller Organization

itemprop

name

Executive Objects

注意:用于从HTML中提取微数据结构的便捷工具是Google的结构化数据测试工具。试试上面显示的HTML

产品规格

规范

状态

评论

物品种类

工作组注意事项 - 不再积极发展

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

Feature

Android

Chrome for Android

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

扫码关注腾讯云开发者

领取腾讯云代金券