itemref
不是具有 itemscope
属性的元素后代的属性可以与使用 全局属性 itemref
的项目关联。
¥Properties that are not descendants of an element with the itemscope
attribute can be associated with an item using the global attribute itemref
.
itemref
提供文档中其他位置的元素 ID(不是 itemid
)列表,以及附加属性
¥itemref
provides a list of element IDs (not itemid
s) elsewhere in the document, with additional properties
只能在指定了 itemscope
属性的元素上指定 itemref
属性。
¥The itemref
attribute can only be specified on elements that have an itemscope
attribute specified.
注意:
itemref
属性不是微数据数据模型的一部分。它只是一种语法结构,可帮助作者向要注释的数据不遵循方便的树结构的页面添加注释。例如,它允许作者标记表中的数据,以便每列定义一个单独的项目,同时保留单元格中的属性。¥Note: The
itemref
attribute is not part of the microdata data model. It is merely a syntactic construct to aid authors in adding annotations to pages where the data to be annotated does not follow a convenient tree structure. For example, it allows authors to mark up data in a table so that each column defines a separate item while keeping the properties in the cells.
示例
表示带的结构化数据
¥Representing structured data for a band
本示例使用微数据属性来表示以下结构化数据(JSON-LD 格式):
¥This example uses microdata attributes to represent the following structured data (in JSON-LD format):
{
"@id": "amanda",
"name": "Amanda",
"band": {
"@id": "b",
"name": "Jazz Band",
"size": 12
}
}
HTML
<div itemscope id="amanda" itemref="a b"></div>
<p id="a">Name: <span itemprop="name">Amanda</span></p>
<div id="b" itemprop="band" itemscope itemref="c"></div>
<div id="c">
<p>Band: <span itemprop="name">Jazz Band</span></p>
<p>Size: <span itemprop="size">12</span> players</p>
</div>
结果
¥Result
规范
Specification |
---|
HTML Standard # attr-itemref |