微資料
是一種規格,可將機器可讀取的資料嵌入 HTML 文件。微資料是由根據詞彙定義的名稱/值組合 (稱為 items
) 所組成。schema.org 提供一系列常用的標記詞彙。
基本語法包含 itemscope
屬性 (用於定義項目) 和 itemprop
屬性 (用於描述項目的其中一個屬性)。類型是使用 itemtype
屬性指定,且可採用所選詞彙中定義的值。舉例來說,schema.org
會定義 http://schema.org/Person
或 http://schema.org/PostalAddress
等型別。
以下範例 (來自 Wikipedia) 說明如何使用微資料描述一個人:
<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>
請使用結構定義驗證工具偵錯標記,並根據支援的結構定義進行驗證。