Nested items

An entity or item is an information type—for example, a Person, an Organization, or a Review. Some entities can include other entities: for example, a restaurant review might contain Person and Organization information such as the reviewer's job title and the address information of the business. In this case, you can convey the relationship between these types of data by nesting person information (reviewer details) and organization information (address details) inside that review.

Including business information in a review

This is an example of a review of a business (L'Amourita Pizza).

<div>
L'Amourita Pizza
Located at 123 Main St, Albequerque, NM.
<a href="http://pizza.example.com">http://pizza.example.com</a>
Reviewed by Bob Smith. 
Rated: 9/10 (Excellent)
<div>

As well as the review itself (the name of the reviewer and the rating), this review also contains information about the subject of the review (the business name and address).

The following sections describe how to mark up this content using microdata, microformats, and RDFa.

To check that your markup is correct, and preview how your content might look in search results, use the structured data testing tool.
Microdata

Here's the same HTML code marked up with microdata:

<div itemscope itemtype="http://data-vocabulary.org/Review">
  <span itemprop="itemreviewed" itemscope itemtype="http://data-vocabulary.org/Organization">
    <span itemprop="name">L’Amourita Pizza</span>
    Located at 
    <span itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">
      <span itemprop="street-address">123 Main St</span>, 
      <span itemprop="locality">Albuquerque</span>, 
      <span itemprop="region">NM</span>.
    </span>
    <a href="http://pizza.example.com" itemprop="url">http://pizza.example.com</a>
  </span>
  Reviewed by <span itemprop="reviewer">Bob Smith</span>. Rated: 
  <span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">
    <span itemprop="value">9</span>/
    <span itemprop="best">10</span> (Excellent)
  </span>
</div>

Here's how this sample works:

  • The Review listing includes Organization information for the restaurant, which in turn includes address information (itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address"), with the properties street-address, locality, and region.
  • It also includes nested Rating information (itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating").
Microformats

To nest a vcard (Organization) inside a review, add vcard to the item class definition (for example: <div class="item vcard">). Be sure to keep item and vcard on the same line, separated by a space and in that order.

<div class="hreview">
   <span class="item vcard">
      <span class="fn">L'Amourita Pizza</span>
      Located at 
      <span class="adr">
         <span class="street-address">123 Main St</span>, 
         <span class="locality">Albequerque</span>,
         <span class="region">NM</span>.
      </span>
      <a href="http://pizza.example.com" class="url">http://pizza.example.com</a>
   </span>
   Reviewed by 
   <span class="reviewer">Bob Smith</span>. 
   Rated: 
   <span class="rating">
      <span class="value">9</span>/
      <span class="best">10</span> (Excellent)
   </span>
</div>

Here's how this sample works:

  • In the first line, class="hreview" indicates that the HTML enclosed in the <div> describes a Review.
  • In the second line, the class="item vcard" indicates that contact information (hCard) is included for L'Amourita Pizza, the subject of the review (item). (Note: The microformat is hCard, but it appears in markup as vcard. It's not a typo.) Be sure to keep item and vcard on the same line, separated by a space and in that order.
  • The hCard includes the properties fn (name) and adr (address), which in turn has subproperties street-address, locality, and region), and url (the website of the restaurant).
RDFa

Here's the same HTML content marked up with RDFa:

<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review">
   <div rel="v:itemreviewed">
      <span typeof="Organization">   
         <span property="v:name">L'Amourita Pizza</span>
         Located at 
         <span rel="v:address">
            <span typeof="v:Address">
               <span property="v:street-address">123 Main St</span>, 
               <span property="v:locality">Albuquerque</span>, 
               <span property="v:region">NM</span>.
            </span>
         </span>
         <a href="http://pizza.example.com/" rel="v:url">http://pizza.example.com</a>
      </span>
   </div>
   Reviewed by 
   <span property="v:reviewer">Bob Smith</span>. 
   Rated: 
   <span rel="v:rating">
       <span property="v:value">9</span>/
       <span property="v:best">10</span> (Excellent)
   </span>
</div>

Here's how this sample works:

  • The example begins with a namespace declaration using xmlns. This indicates the namespace where the vocabulary (a list of entities and their components) is specified. You can use the xmlns:v="http://rdf.data-vocabulary.org/#" namespace declaration any time you are marking up pages for people, review, or place data. Be sure to use a trailing slash and # (xmlns:v="http://rdf.data-vocabulary.org/#").
  • Also on the first line, typeof="v:Review" indicates that the marked-up content is a Review.
  • In this case, we want to include the business's information (typeof="v:Organization") in the typeof="v:Review" entity. Here, we use rel to indicate a relationship between L'Amourita Pizza (the entity v:itemreviewed) and its contact information (the entity v:Organization). Then, we include <span typeof="v:Organization"></span> to include the actual business contact entity.

Including organization information in an Event

The following example shows a concert listing that includes a specific venue.

 
<div>
<a href="http://www.example.com/events/spinaltap">Spinal Tap</a>
Where: Warfield Theatre, 982 Market St, San Francisco, CA
When: Oct 15, 7:00PM—9:00PM
</div>
Microdata

Here is the same HTML code marked up with microdata:

<div itemscope itemtype="http://data-vocabulary.org/Event">
  ​<a href="http://www.example.com/events/spinaltap" itemprop="url" >
    <span itemprop="summary">Spinal Tap</span>
  </a>
  Where:
  ​<span itemprop="location" itemscope itemtype="http://data-vocabulary.org/​Organization">
     ​<span itemprop="name">Warfield Theatre</span>
     ​<span itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">
         <span itemprop="street-address">982 Market St</span>, 
         <span itemprop="locality">San Francisco</span>, 
         <span itemprop="region">CA</span>
     </span>
  </span>
  When:
  <time itemprop="startDate" datetime="2009-10-15T19:00-08:00">Oct 15, 7:00PM</time>—
  <time itemprop="endDate" datetime="2009-10-15T21:00-08:00">9:00PM</time>
</div>

Here's how this sample works:

  • The Event listing includes Organization information for the event venue. This in turn contains nested Address information (itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address"), with the properties street-address, locality, and region.
Microformats

Here is the same content marked up using microformats:

 
<div class="vevent">
   <a href="http://www.example.com/events/spinaltap" class="url summary">Spinal Tap</a>
   Where: 
   <div class="location vcard">
      <span class="fn org">Warfield Theatre</span>
      <span class="adr">
         <span class="street-address">982 Market St</span>, 
         <span class="locality">San Francisco</span>, 
         <span class="region">CA</span>
      </span>
   </div>
   When: 
   <span class="dtstart">
      <span class="value-title" title="2009-10-15T19:00-08:00">Oct 15, 7:00PM</span>
   </span> 
   <span class="dtend">
      <span class="value-title" title="2009-10-15T21:00-08:00">9:00PM</span>
  </span>
</div>

Here's how this sample works:

  • In the first line, class="vevent" indicates that the HTML enclosed in the <div> describes a Review.
  • In the third line, the class="location vcard" indicates that contact information (vcard) is included for the event venue (location).
  • On the fourth line, class="fn org" indicates that the vcard describes a business or organization.
  • The vcard includes the venue address property adr (address, which in turn has the subproperties street-address, locality, and region).
RDFa

Here is the same content marked up with RDFa:

<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Event"> 
  <a href="http://www.example.com/events/spinaltap" rel="v:url" property="v:summary">Spinal Tap</a>

  Where: 
  <span rel="v:location">
    <span typeof="v:Organization">
      <span property="v:name">Warfield Theatre</span>,
      <span rel="v:address">
        <span typeof="v:Address">
          <span property="v:street-address">982 Market St</span>, 
          <span property="v:locality">San Francisco</span>, 
          <span property="v:region">CA</span>
        </span>
      </span>
   </span>
      <span rel="v:geo">
        <span typeof="v:Geo">
          <span property="v:latitude" content="37.774929"></span>
          <span property="v:longitude" content="-122.419416"></span>
        </span>
      </span>
  </span>   

  When: 
  <span property="v:startDate" content="2009-10-15T19:00-08:00">Oct 15, 7:00PM</span>—
  <span property="v:endDate" content="2009-10-15T21:00-08:00">9:00PM</span>
</div>

Here's how this sample works:

  • The Event listing includes Organization information for the event venue. This in turn contains nested Address information (<span typeof="v:Address">), with the properties street-address, locality, and region.