微数据

微数据是一种在 HTML 文档中嵌入机器可读数据的规范。微数据由根据词汇表定义的名称值对(称为 items)组成。schema.org 提供了一系列常用的标记词汇表。

基本语法包括用于定义商品的 itemscope 属性和用于描述某个商品属性的 itemprop 属性。类型使用 itemtype 属性指定,可以接受所选词汇中定义的值。例如,schema.org 定义了 http://schema.org/Personhttp://schema.org/PostalAddress 等类型。

以下示例(来自维基百科)展示了如何使用微数据来描述人物:

<section itemscope itemtype="http://schema.org/Person">
  Hello, my name is
  <span itemprop="name">John Doe</span>,
  I am a
  <span itemprop="jobTitle">Graduate research assistant</span>
  at the
  <span itemprop="affiliation">University of Dreams</span>
  My friends call me
  <span itemprop="additionalName">Johnny</span>
  You can visit my homepage at
  <a href="http://www.example.com.com" itemprop="url">www.example.com</a>
  <section itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
    I live at
    <span itemprop="streetAddress">1234 Peach Drive</span>
    <span itemprop="addressLocality">Warner Robins</span>
    <span itemprop="addressRegion">Georgia</span>.
  </section>
</section>

请检查架构验证器工具,以调试标记并根据支持的架构对其进行验证。