aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/html/global_attributes/itemprop/index.html
blob: 06a11f013d5920cb97e3c075a17d40a68283011c (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
---
title: itemprop
slug: Web/HTML/Global_attributes/itemprop
tags:
  - Atributos
  - Atributos globais
  - HTML
  - Referências
  - itemprop
translation_of: Web/HTML/Global_attributes/itemprop
---
<div>{{HTMLSidebar("Global_attributes")}}</div>

<p>O atributo global  <code><strong>itemprop</strong></code> é usado para adicionar propriedades para um item. Todo elemento HTML pode ter um atributo <code>itemprop</code>  especificado, e um <code>itemprop</code> consiste em um par de nome e valor. Cada par de nome e valor é chamado de <strong>propriedade,</strong> e um grupo de uma ou mais propriedades forma um <strong>item</strong>. Os valores das propriedades são ou um texto ou uma URL e pode ser associada a uma grande variedade de elementos incluindo {{HTMLElement("audio")}}{{HTMLElement("embed")}}{{HTMLElement("iframe")}}{{HTMLElement("img")}}{{HTMLElement("link")}}{{HTMLElement("object")}}{{HTMLElement("source")}} , {{HTMLElement("track")}}, and {{HTMLElement("video")}}.</p>

<h2 id="Exemplos">Exemplos</h2>

<p>The example below shows the source for a set of elements marked up with <code>itemprop</code> attributes, followed by a table showing the resulting structured data.</p>

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

<pre class="brush: html">&lt;div itemscope itemtype ="http://schema.org/Movie"&gt;
  &lt;h1 <strong>itemprop="name"</strong>&gt;Avatar&lt;/h1&gt;
  &lt;span&gt;Director:
    &lt;span <strong>itemprop="director"</strong>&gt;James Cameron&lt;/span&gt;
    (born August 16, 1954)&lt;/span&gt;
  &lt;span <strong>itemprop="genre"</strong>&gt;Science fiction&lt;/span&gt;
  &lt;a href="../movies/avatar-theatrical-trailer.html"
    <strong>itemprop="trailer"</strong>&gt;Trailer&lt;/a&gt;
&lt;/div&gt;</pre>

<h3 id="Structured_data">Structured data</h3>

<table class="standard-table">
 <tbody>
  <tr>
   <td colspan="1" rowspan="2"> </td>
   <th colspan="2" rowspan="1"><strong>Item</strong></th>
  </tr>
  <tr>
   <th><strong>itemprop name</strong></th>
   <th><strong>itemprop value</strong></th>
  </tr>
  <tr>
   <td>itemprop</td>
   <td>name</td>
   <td>Avatar</td>
  </tr>
  <tr>
   <td>itemprop</td>
   <td>director</td>
   <td>James Cameron</td>
  </tr>
  <tr>
   <td>itemprop</td>
   <td>genre</td>
   <td>Science fiction</td>
  </tr>
  <tr>
   <td>itemprop</td>
   <td>trailer</td>
   <td>../movies/avatar-theatrical-trailer.html</td>
  </tr>
 </tbody>
</table>

<h2 id="Properties">Properties</h2>

<p>Properties have values that are either a string or a URL. When a string value is a URL, it is expressed using the {{HTMLElement("a")}} element and its {{htmlattrxref("href", "a")}} attribute, the {{HTMLElement("img")}} element and its {{htmlattrxref("src", "img")}} attribute, or other elements that link to or embed external resources.</p>

<h3 id="Three_properties_with_values_that_are_strings">Three properties with values that are strings</h3>

<pre class="brush: html">&lt;div itemscope&gt;
 &lt;p&gt;My name is
   &lt;span itemprop="name"&gt;Neil&lt;/span&gt;.&lt;/p&gt;
 &lt;p&gt;My band is called
   &lt;span itemprop="band"&gt;Four Parts Water&lt;/span&gt;.&lt;/p&gt;
 &lt;p&gt;I am
   &lt;span itemprop="nationality"&gt;British&lt;/span&gt;.&lt;/p&gt;
&lt;/div&gt;</pre>

<h3 id="One_property_image_whose_value_is_a_URL">One property, "image", whose value is a URL</h3>

<pre class="brush: html">&lt;div itemscope&gt;
 &lt;img itemprop="image"
   src="google-logo.png" alt="Google"&gt;
&lt;/div&gt;</pre>

<p>When a string value can't be easily read and understood by a person (e.g., a long string of numbers and letters), it can be displayed using the value attribute of the data element, with the more easily-understood-by-a human-version given in the element's contents (which is not part of the structured data - see example below).</p>

<h3 id="An_item_with_a_property_whose_value_is_a_product_ID">An item with a property whose value is a product ID</h3>

<p>The ID is not human-friendly, so the product's name is used the human-visible text instead of the ID.</p>

<pre class="brush: html">&lt;h1 itemscope&gt;
 &lt;data itemprop="product-id"
   value="9678AOU879"&gt;The Instigator 2000&lt;/data&gt;
&lt;/h1&gt;</pre>

<p>For numeric data, the meter element and its value attribute can be used.</p>

<h3 id="A_meter_element">A meter element</h3>

<pre class="brush: html">&lt;div itemscope itemtype="http://schema.org/Product"&gt;
 &lt;span itemprop="name"&gt;Panasonic White
   60L Refrigerator&lt;/span&gt;
 &lt;img src="panasonic-fridge-60l-white.jpg" alt=""&gt;
  &lt;div itemprop="aggregateRating"
       itemscope
       itemtype="http://schema.org/AggregateRating"&gt;
   &lt;meter itemprop="ratingValue"
     min=0 value=3.5 max=5&gt;Rated 3.5/5&lt;/meter&gt;
   (based on &lt;span
     itemprop="reviewCount"&gt;11&lt;/span&gt;
     customer reviews)
  &lt;/div&gt;
&lt;/div&gt;</pre>

<p>Similarly, for date- and time-related data, the time element and its datetime attribute can be used.</p>

<h3 id="An_item_with_one_property_birthday_whose_value_is_a_date">An item with one property, "birthday", whose value is a date</h3>

<pre class="brush: html">&lt;div itemscope&gt;
 I was born on &lt;time
   itemprop="birthday"
   datetime="2009-05-10"&gt;May 10th 2009&lt;/time&gt;.
&lt;/div&gt;</pre>

<p>Properties can also be groups of name-value pairs, by putting the itemscope attribute on the element that declares the property. Each value is either a string or a group of name-value pairs (i.e. an item).</p>

<h3 id="An_outer_item_representing_a_person_and_an_inner_one_representing_a_band">An outer item representing a person, and an inner one representing a band</h3>

<pre class="brush: html">&lt;div itemscope&gt;
 &lt;p&gt;Name:
   &lt;span itemprop="name"&gt;Amanda&lt;/span&gt;&lt;/p&gt;
 &lt;p&gt;Band:
   &lt;span itemprop="band" itemscope&gt;
     &lt;span itemprop="name"&gt;Jazz Band&lt;/span&gt;
     (&lt;span itemprop="size"&gt;12&lt;/span&gt;
     players)&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;</pre>

<p>The outer item above has two properties, "name" and "band". The "name" is "Amanda", and the "band" is an item in its own right, with two properties, "name" and "size". The "name" of the band is "Jazz Band", and the "size" is "12". The outer item in this example is a top-level microdata item. Items that are not part of others are called top-level microdata items.</p>

<h3 id="All_the_properties_separated_from_their_items">All the properties separated from their items</h3>

<p>This example is the same as the previous one, but all the properties are separated from their items</p>

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

<p>This gives the same result as the previous example. The first item has two properties, "name", set to "Amanda", and "band", set to another item. That second item has two further properties, "name", set to "Jazz Band", and "size", set to "12".</p>

<p>An item can have multiple properties with the same name and different values.</p>

<h3 id="Ice_cream_with_two_flavors">Ice cream with two flavors</h3>

<pre class="brush: html">&lt;div itemscope&gt;
 &lt;p&gt;Flavors in my favorite ice cream:&lt;/p&gt;
 &lt;ul&gt;
  &lt;li itemprop="flavor"&gt;Lemon sorbet&lt;/li&gt;
  &lt;li itemprop="flavor"&gt;Apricot sorbet&lt;/li&gt;
 &lt;/ul&gt;
&lt;/div&gt;</pre>

<p>This results in an item with two properties, both with the name "flavor" and having the values "Lemon sorbet" and "Apricot sorbet".</p>

<p>An element introducing a property can also introduce multiple properties at once, to avoid duplication when some of the properties have the same value.</p>

<h3 id="An_item_with_two_properties_favorite-color_and_favorite-fruit_both_set_to_the_value_orange">An item with two properties, "favorite-color" and "favorite-fruit", both set to the value "orange"</h3>

<pre class="brush: html">&lt;div itemscope&gt;
 &lt;span
  itemprop="favorite-color
    favorite-fruit"&gt;orange&lt;/span&gt;
&lt;/div&gt;</pre>

<div class="note">
<p>Note: There is no relationship between the microdata and the content of the document where the microdata is marked up.</p>
</div>

<h3 id="Same_structured_data_marked_up_in_two_different_ways">Same structured data marked up in two different ways</h3>

<p id="There_is_no_semantic_difference_between_the_following_two_examples">There is no semantic difference between the following two examples</p>

<pre class="brush: html">&lt;figure&gt;
 &lt;img src="castle.jpeg"&gt;
 &lt;figcaption&gt;&lt;span
   itemscope&gt;&lt;span
   itemprop="name"&gt;The Castle&lt;/span&gt;&lt;/span&gt;
     (1986)&lt;/figcaption&gt;
&lt;/figure&gt;</pre>

<pre class="brush: html">&lt;span itemscope&gt;&lt;meta
  itemprop="name"
  content="The Castle"&gt;&lt;/span&gt;
&lt;figure&gt;
 &lt;img src="castle.jpeg"&gt;
 &lt;figcaption&gt;The Castle
  (1986)&lt;/figcaption&gt;
&lt;/figure&gt;</pre>

<p>Both have a figure with a caption, and both, completely unrelated to the figure, have an item with a name-value pair with the name "name" and the value "The Castle". The only difference is that if the user drags the figcaption out of the document, the item will be included in the drag-and-drop data. The image associated with the item won't be included.</p>

<h2 id="Names_and_values">Names and values</h2>

<p>A property is an unordered set of unique tokens that are case-sensitive and represent the name-value pairs. The property value must have at least one token. In the example below, each data cell is a token.</p>

<h3 id="Names_examples">Names examples</h3>

<table class="standard-table">
 <thead>
  <tr>
   <th colspan="1" rowspan="2" scope="col"> </th>
   <th colspan="2" rowspan="1" scope="col">Item</th>
  </tr>
  <tr>
   <th scope="col">itemprop <strong>name</strong></th>
   <th scope="col">itemprop <strong>value</strong></th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <th>itemprop</th>
   <td>country</td>
   <td>Ireland</td>
  </tr>
  <tr>
   <th>itemprop</th>
   <td>Option</td>
   <td>2</td>
  </tr>
  <tr>
   <th>itemprop</th>
   <td>https://www.flickr.com/photos/nlireland/6992065114/</td>
   <td>Ring of Kerry</td>
  </tr>
  <tr>
   <th>itemprop</th>
   <td>img</td>
   <td>https://www.flickr.com/photos/nlireland/6992065114/</td>
  </tr>
  <tr>
   <th>itemprop</th>
   <td>website</td>
   <td>flickr</td>
  </tr>
  <tr>
   <th>itemprop</th>
   <td>(token)</td>
   <td>(token)</td>
  </tr>
 </tbody>
</table>

<p><strong>Tokens </strong>are either strings or URL's. An item is called a <strong>typed item</strong> if it is a URL. Otherwise, it is a string. Strings cannot contain a period or a colon (see below).</p>

<ol>
 <li>If the item is a typed item it must be either:
  <ol>
   <li>A defined property name, or</li>
   <li>A valid URL, which refers to the vocabulary definition, or</li>
   <li>A valid URL that is used as a proprietary item property name (i.e. one not defined in a public specification), or</li>
  </ol>
 </li>
 <li>If the item is not a typed item it must be:
  <ol>
   <li>A string that contains no "<strong>.</strong>" (U+002E FULL STOP) characters and no "<strong>:</strong>" characters (U+003A COLON) and is used as a proprietary item property name (again, one not defined in a public specification).</li>
  </ol>
 </li>
</ol>

<p class="note"><strong>Note:</strong> the rules above disallow ":" characters in non-URL values because otherwise they could not be distinguished from URLs. Values with "." characters are reserved for future extensions. Space characters are disallowed because otherwise the values would be parsed as multiple tokens.</p>

<h2 id="Values">Values</h2>

<p>The property value of a name-value pair is as given for the first matching case in the following list:</p>

<ul>
 <li>If the element has an <strong>itemscope </strong>attribute

  <ul>
   <li>The value is the <strong>item </strong>created by the element.</li>
  </ul>
 </li>
 <li>If the element is a <strong>meta </strong>element
  <ul>
   <li>The value is the value of the element's <strong>content </strong>attribute</li>
  </ul>
 </li>
 <li>If the element is an <strong>audio</strong>, <strong>embed</strong>, <strong>iframe</strong>, <strong>img</strong>, <strong>source</strong>, <strong>track</strong>, or <strong>video </strong>element
  <ul>
   <li>The value is the resulting URL string that results from parsing the value of the element's src attribute relative to the node document (part of the <a href="/en-US/docs/Web/API/Microdata_DOM_API">Microdata DOM API</a>) of the element at the time the attribute is set</li>
  </ul>
 </li>
 <li>If the element is an <strong>a</strong>, <strong>area</strong>, or <strong>link </strong>element
  <ul>
   <li>The value is the resulting URL string that results from parsing the value of the element's href attribute relative to the node document of the element at the time the attribute is set</li>
  </ul>
 </li>
 <li>If the element is an <strong>object </strong>element
  <ul>
   <li>The value is the resulting URL string that results from parsing the value of the element's data attribute relative to the node document of the element at the time the attribute is set</li>
  </ul>
 </li>
 <li>If the element is a <strong>data </strong>element
  <ul>
   <li>The value is the value of the element's value attribute</li>
  </ul>
 </li>
 <li>If the element is a <strong>meter </strong>element
  <ul>
   <li>The value is the value of the element's <strong>value </strong>attribute</li>
  </ul>
 </li>
 <li>If the element is a <strong>time </strong>element
  <ul>
   <li>The value is the element's <strong>datetime </strong>value</li>
  </ul>
 </li>
</ul>

<p>Otherwise</p>

<ul>
 <li>The value is the element's <strong>textContent</strong>.</li>
</ul>

<p>If a property's value is a<strong> URL</strong>, the property must be specified using a URL property element. The URL property elements are the <strong>a</strong>, <strong>area</strong>, <strong>audio</strong>, <strong>embed</strong>, <strong>iframe</strong>, <strong>img</strong>, <strong>link</strong>, <strong>object</strong>, <strong>source</strong>, <strong>track</strong>, and <strong>video </strong>elements.</p>

<h3 id="Name_order">Name order</h3>

<p>Names are unordered relative to each other, but if a particular name has multiple values, they do have a relative order.</p>

<h4 id="In_the_following_example_the_a_property_has_the_values_1_and_2_in_that_order_but_whether_the_a_property_comes_before_the_b_property_or_not_is_not_important">In the following example, the "a" property has the values "1" and "2", <em>in that order</em>, but whether the "a" property comes before the "b" property or not is not important</h4>

<pre class="brush: html">&lt;div itemscope&gt;
 &lt;p itemprop="a"&gt;1&lt;/p&gt;
 &lt;p itemprop="a"&gt;2&lt;/p&gt;
 &lt;p itemprop="b"&gt;test&lt;/p&gt;
&lt;/div&gt;</pre>

<h4 id="The_following_is_equivalent">The following is equivalent</h4>

<pre class="brush: html">&lt;div itemscope&gt;
 &lt;p itemprop="b"&gt;test&lt;/p&gt;
 &lt;p itemprop="a"&gt;1&lt;/p&gt;
 &lt;p itemprop="a"&gt;2&lt;/p&gt;
&lt;/div&gt;</pre>

<h4 id="As_is_the_following">As is the following</h4>

<pre class="brush: html">&lt;div itemscope&gt;
 &lt;p itemprop="a"&gt;1&lt;/p&gt;
 &lt;p itemprop="b"&gt;test&lt;/p&gt;
 &lt;p itemprop="a"&gt;2&lt;/p&gt;
&lt;/div&gt;</pre>

<h4 id="And_the_following">And the following</h4>

<pre class="brush: html">&lt;div id="x"&gt;
 &lt;p itemprop="a"&gt;1&lt;/p&gt;
&lt;/div&gt;
&lt;div itemscope itemref="x"&gt;
 &lt;p itemprop="b"&gt;test&lt;/p&gt;
 &lt;p itemprop="a"&gt;2&lt;/p&gt;
&lt;/div&gt;
</pre>

<h2 id="Other_examples">Other examples</h2>

<h3 id="HTML_2">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="Structured_data_2">Structured data</h3>

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

<h3 id="Result">Result</h3>

<p>{{EmbedLiveSample('HTML_2', '', '', '', 'Web/HTML/Global_attributes/itemprop')}}</p>

<h2 id="Specifications">Specifications</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#names:-the-itemprop-attribute:names:-the-itemprop-attribute">itemprop</a></code></td>
   <td> </td>
   <td>WG Note - No longer being actively developed</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</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 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>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/HTML/Global_attributes">Other different global attributes</a></li>
 <li>Other, microdata related, global attributes:
  <ul>
   <li>{{htmlattrxref("itemid")}}</li>
   <li>{{htmlattrxref("itemprop")}}</li>
   <li>{{htmlattrxref("itemref")}}</li>
   <li>{{htmlattrxref("itemscope")}}</li>
   <li>{{htmlattrxref("itemtype")}}</li>
  </ul>
 </li>
</ul>
</div>
</div>