aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/global_attributes/itemid/index.html
blob: 6d42d5bca7204f66afd78df00054cdd65874f819 (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
---
title: itemid
slug: Web/HTML/Global_attributes/itemid
tags:
  - Attribute
  - Global attribute
  - HTML
  - Microdata
  - Reference
translation_of: Web/HTML/Global_attributes/itemid
---
<div>{{HTMLSidebar("Global_attributes")}}</div>

<p><code><strong>itemid</strong></code> <a href="/en-US/docs/Web/HTML/Global_attributes">全局属性</a> 是元素的唯一的全局标识符。<code>itemid</code> 属性只能为同时拥有 <strong><code>itemscope</code> </strong>和 <strong><code>itemtype</code></strong> 的元素指定。同时,<code>itemid</code> 只能为拥有 <code>itemscope</code> 的元素指定,它的相应 <code>itemtype</code> 引用或定义了支持全局标识符的词汇。</p>

<p><code>itemtype</code> 的全局标识符的准确含义,由该标识符以指定的词汇提供。词汇定义了全局标识符相同的多个元素是否可以共存,并且如果是这样,这些元素如何处理。 </p>

<p class="note"><strong>注:</strong>Whatwg.org 的定义规定了 <code>itemid</code> 必须是 URL。但是,下面的示例正确展示了 URN 也可以使用。这个不一致性可能反映了 Microdata 规范的不完善性。</p>

<h2 id="示例">示例</h2>

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;dl itemscope
    itemtype="http://vocab.example.net/book"
    itemid="urn:isbn:0-330-34032-8"&gt;
&lt;dt&gt;Title &lt;dd itemprop="title"&gt;The Reality Dysfunction
&lt;dt&gt;Author &lt;dd itemprop="author"&gt;Peter F. Hamilton
&lt;dt&gt;Publication date
&lt;dd&gt;&lt;time itemprop="pubdate" datetime="1996-01-26"&gt;26 January 1996&lt;/time&gt; &lt;/dl&gt;</pre>

<h3 id="结构化数据">结构化数据</h3>

<table class="standard-table">
 <tbody>
  <tr>
   <td colspan="1" rowspan="14">itemscope</td>
   <td>itemtype: itemid</td>
   <td colspan="2" rowspan="1">
    <div class="jyrRxf-eEDwDf jcd3Mb IZ65Hb-hUbt4d">http://vocab.example.net/book: urn:isbn:0-330-34032-8</div>
   </td>
  </tr>
  <tr>
   <td>itemprop</td>
   <td>title</td>
   <td>The Reality Dysfunction</td>
  </tr>
  <tr>
   <td>itemprop</td>
   <td>author</td>
   <td>
    <div class="jyrRxf-eEDwDf jcd3Mb">Peter F. Hamilton</div>
   </td>
  </tr>
  <tr>
   <td>itemprop</td>
   <td>pubdate</td>
   <td>1996-01-26</td>
  </tr>
 </tbody>
</table>

<h3 id="结果">结果</h3>

<p>{{EmbedLiveSample('示例')}}</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#attr-itemid">itemid</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="/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>