blob: a16ec3bf276fced3a032ded140cd40edc2c39af9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
---
title: itemref
slug: Web/HTML/Global_attributes/itemref
translation_of: Web/HTML/Global_attributes/itemref
---
<div>{{HTMLSidebar("Global_attributes")}}</div>
<p><span class="seoSummary"><strong><code>itemref</code></strong> <a href="/en-US/docs/Web/HTML/Global_attributes">全局属性</a> 不具有 <code>itemscope</code> 属性的元素的后代,才可以与具有 <code><strong>itemref</strong></code> 的元素关联。</span><code>itemref</code><span class="seoSummary"> 提供了元素 id(并不是 </span><code>itemid</code><span class="seoSummary">)的列表,并具有文档其它地方的额外属性。</span></p>
<p><code>itemref</code> 属性只能在指定了 <code>itemscope</code> 的元素上指定。</p>
<p class="note"><strong>注:</strong><code>itemref</code> 属性并不是 microdata 数据模型的一部分。它仅仅是个语义结构,用于帮助作者向页面添加注解,其中被注解的数据不遵循便利的树结构。例如,它允许作者标记表格中的数据,以便每一列定义一个单独的条目,同时在表格中保留属性。</p>
<h2 id="示例">示例</h2>
<h3 id="HTML">HTML</h3>
<pre class="brush: 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>
</pre>
<h3 id="结构化数据">结构化数据</h3>
<table class="standard-table">
<tbody>
<tr>
<th>id's</th>
<th>itemscope</th>
<th>itemref</th>
<th></th>
<th>(itemprop name)</th>
<th>(itemprop value)</th>
</tr>
<tr>
<td>id=amanda</td>
<td>itemscope</td>
<td>itemref=a,b</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>id=a</td>
<td></td>
<td></td>
<td>itemprop</td>
<td>name</td>
<td>Amanda</td>
</tr>
<tr>
<td>id=b</td>
<td>itemscope</td>
<td>itemref=c</td>
<td></td>
<td>band</td>
<td></td>
</tr>
<tr>
<td colspan="1" rowspan="2">id=c</td>
<td></td>
<td></td>
<td>itemprop</td>
<td>Band</td>
<td>Jazz Band</td>
</tr>
<tr>
<td></td>
<td></td>
<td>itemprop</td>
<td>Size</td>
<td>12</td>
</tr>
</tbody>
</table>
<h3 id="结果">结果</h3>
<p>{{EmbedLiveSample('Example', '', '', '', 'Web/HTML/Global_attributes/itemref')}}</p>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td><code><a href="https://html.spec.whatwg.org/multipage/microdata.html#items">itemref</a></code></td>
<td></td>
<td>WG Note - No longer being actively developed</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<h2 id="参阅">参阅</h2>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes">其它不同的全局属性</a></li>
<li>其它 microdata 相关的全局属性
<ul>
<li>{{htmlattrxref("itemid")}}</li>
<li>{{htmlattrxref("itemprop")}}</li>
<li>{{htmlattrxref("itemref")}}</li>
<li>{{htmlattrxref("itemscope")}}</li>
<li>{{htmlattrxref("itemtype")}}</li>
</ul>
</li>
</ul>
|