微資料
微資料是一種規格,可在 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>
請使用結構定義驗證工具來偵錯標記,並根據支援的結構定義驗證標記。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-21 (世界標準時間)。
[null,null,["上次更新時間:2024-12-21 (世界標準時間)。"],[[["Microdata is an HTML specification used to embed machine-readable data in webpages using name-value pairs called `items` which are defined within a vocabulary."],["Schema.org provides commonly used vocabularies to structure the data, and items are marked up with attributes like `itemscope`, `itemprop`, and `itemtype` for machines to understand."],["The syntax involves defining an `item` and its `properties` using these attributes, and specifying a vocabulary such as schema.org for types like `Person` or `PostalAddress`."],["You can validate your Microdata implementation using the Schema Validator tool to ensure correctness and compatibility with supported schemas."]]],["Microdata embeds machine-readable data in HTML using name-value pairs called items. `itemscope` defines an item, `itemprop` describes its properties, and `itemtype` specifies its type from a vocabulary (e.g., schema.org). For example, the `Person` type can include properties like `name`, `jobTitle`, and `address`. The Schema Validator tool is available for debugging and validating microdata markup against supported schemas.\n"]]