itemref - HTML: HyperText Markup Language 编辑
Properties that are not descendants of an element with the itemscope
attribute can be associated with an item using the global attribute itemref
.
itemref
provides a list of element IDs (not itemid
s) elsewhere in the document, with additional properties
The itemref
attribute can only be specified on elements that have an itemscope
attribute specified.
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.
Example
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>
Structured data
(in JSON-LD format)
{
"@id": "amanda",
"name": "Amanda",
"band": {
"@id": "b",
"name": "Jazz Band",
"size": 12
}
}
Result
Specifications
Specification | Status | Comment |
---|---|---|
HTML Microdata The definition of 'itemref' in that specification. | Working Draft | |
HTML Living Standard The definition of 'itemref' in that specification. | Living Standard |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论