Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

itemprop

현재 번역은 완벽하지 않습니다. 한국어로 문서 번역에 동참해주세요.

개요

itemprop 속성은 아이템에 항목을 추가할때 주로 사용한다.  모든 HTML 요소는 특정화된(구별된) itemprop 속성을 가질 수 있다. 하나의 itemprop 은 이름-값의 쌍으로 구성된다. 각 이름-값의 쌍은 property로 불리어지고, 하나의 그룹 또는 그 이상의 요소형태로 하나의 item이 된다.  Property 값은  문자열(String) 이거나   audio, embed, iframe, img, link, object, source, track, 와  video 를 포함한 넒은 의미의 요소와 관련한 URL 값이다. 

Simple example

HTML

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

 

Structured data

  Item
itemprop name itemprop value
itemprop name Avatar
itemprop director James Cameron
itemprop genre Science fiction
itemprop trailer ../movies/avatar-theatrical-trailer.html

Properties

Properties 는 문자열이나 URL값을 갖는다. URL 문자값을 가질때는, 자신의 href 값이나 이미지 요소의 src 값 또는연결(link) 또는 내장된 별도의 요소경로로 표현 되어진다. 

문자를 값으로 가진 세가지 요소항목(properties)

<div itemscope>
 <p>My name is <span itemprop="name">Neil</span>.</p>
 <p>My band is called <span itemprop="band">Four Parts Water</span>.</p>
 <p>I am <span itemprop="nationality">British</span>.</p>
</div>

URL값을 가진 image 요소값으로의 표현 

<div itemscope>
 <img itemprop="image" src="google-logo.png" alt="Google">
</div>

문자값일 경우 사람들에게 쉽게 읽히거나 이해되기 쉽지않다. (예를 들어 긴 문자의 숫자값이나 긴 문장일 경우), 이 경우는 좀더 인간이 인지하기 쉬운 방식으로 요소내용을 data 항목 요소로 표시한 값을 사용하면 쉽게 구별되어질 수 있다. ,  (구조화된 데이터의 일부가 아니라도 - 아래의 예제를 참고하라).

product ID 값을 요소로 가진 항목. ID의  문자열은 인식하기 어려우므로 상품의 이름은 ID 대신에 사람이 인지하기 좋은 문자를 ID 대신 사용하였다.

<h1 itemscope>
 <data itemprop="product-id" value="9678AOU879">The Instigator 2000</data>
</h1>

숫자형 데이터나, 계량 요소 , 자체 값 항목으로 사용 될 수 있다. 

계량요소(A meter element) 의 예

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

비슷하게, 날짜나 시간 관련 데이터, 시간 항목 그리고 날짜  요소로 사용될 수 있다.

In this example, the item has one property, "birthday", whose value is a date

<div itemscope>
 I was born on <time itemprop="birthday" datetime="2009-05-10">May 10th 2009</time>.
</div>

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

In this example, the outer item represents a person, and the inner one represents a band

<div itemscope>
 <p>Name: <span itemprop="name">Amanda</span></p>
 <p>Band: <span itemprop="band" itemscope> <span itemprop="name">Jazz Band</span> (<span itemprop="size">12</span> players)</span></p>
</div>

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.

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

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

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

An item can have multiple properties with the same name and different values.

This example describes an ice cream, with two flavors

<div itemscope>
 <p>Flavors in my favorite ice cream:</p>
 <ul>
  <li itemprop="flavor">Lemon sorbet</li>
  <li itemprop="flavor">Apricot sorbet</li>
 </ul>
</div>

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

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

Here we see an item with two properties, "favorite-color" and "favorite-fruit", both set to the value "orange"

<div itemscope>
 <span itemprop="favorite-color favorite-fruit">orange</span>
</div>

Note: There is no relationship between the microdata and the content of the document where the microdata is marked up.

There is no semantic difference between the following two examples

<figure>
 <img src="castle.jpeg">
 <figcaption><span itemscope><span itemprop="name">The Castle</span></span> (1986)</figcaption>
</figure>
<span itemscope><meta itemprop="name" content="The Castle"></span>
<figure>
 <img src="castle.jpeg">
 <figcaption>The Castle (1986)</figcaption>
</figure>

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.

Names and values

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.

Names examples

  Item
itemprop name itemprop value
itemprop country Ireland
itemprop Option 2
itemprop https://www.flickr.com/photos/nlireland/6992065114/ Ring of Kerry
itemprop img https://www.flickr.com/photos/nlireland/6992065114/
itemprop website flickr
itemprop (token) (token)

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

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

Note: 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.

Values

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

  • If the element has an itemscope attribute
    • The value is the item created by the element.
  • If the element is a meta element
    • The value is the value of the element's content attribute
  • If the element is an audio, embed, iframe, img, source, track, or video element
    • 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 Microdata DOM API) of the element at the time the attribute is set
  • If the element is an a, area, or link element
    • 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
  • If the element is an object element
    • 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
  • If the element is a data element
    • The value is the value of the element's value attribute
  • If the element is a meter element
    • The value is the value of the element's value attribute
  • If the element is a time element
    • The value is the element's datetime value

Otherwise

  • The value is the element's textContent.

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

Name order

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

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

<div itemscope>
 <p itemprop="a">1</p>
 <p itemprop="a">2</p>
 <p itemprop="b">test</p>
</div>

The following is equivalent

<div itemscope>
 <p itemprop="b">test</p>
 <p itemprop="a">1</p>
 <p itemprop="a">2</p>
</div>

As is the following

<div itemscope>
 <p itemprop="a">1</p>
 <p itemprop="b">test</p>
 <p itemprop="a">2</p>
</div>

And the following

<div id="x">
 <p itemprop="a">1</p>
</div>
<div itemscope itemref="x">
 <p itemprop="b">test</p>
 <p itemprop="a">2</p>
</div>

ExampleEdit

HTML

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

Structured data

itemscope itemtype: itemid
https://vocab.example.net/book: urn:isbn:0-330-34032-8
itemprop title The Reality Dysfunction
itemprop author
Peter F. Hamilton
itemprop pubdate 1996-01-26

Result

SpecificationEditEdit

Specification Status
itemprop WG Note - No longer being actively developed

문서 태그 및 공헌자

 이 페이지의 공헌자: sansolmom
 최종 변경: sansolmom,