aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/global_attributes/itemref/index.html
blob: 3857a78be599d5059259c73c163bf585a663ce85 (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
---
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">&lt;div itemscope id="amanda" itemref="a b"&gt;&lt;/div&gt;
&lt;p id="a"&gt;Name: &lt;span itemprop="name"&gt;Amanda&lt;/span&gt; &lt;/p&gt;
&lt;div id="b" itemprop="band" itemscope itemref="c"&gt;&lt;/div&gt;
&lt;div id="c"&gt;
    &lt;p&gt;Band: &lt;span itemprop="name"&gt;Jazz Band&lt;/span&gt; &lt;/p&gt;
    &lt;p&gt;Size: &lt;span itemprop="size"&gt;12&lt;/span&gt; players&lt;/p&gt;
&lt;/div&gt;
</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>

{{Compat("html.global_attributes.itemref")}}

<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>