About RDFa

Marking up content using RDFa

RDFa is a way to label content to describe a specific type of information, such as a restaurant review, an event, a person, or a product listing. These information types are called entities or items. Each entity has a number of properties. For example, a Person has the properties name, address, job title, company, and email address.

In general, RDFa uses simple attributes in XHTML tags (often <span> or <div>) to assign brief and descriptive names to entities and properties. Here's an example of a short HTML block showing basic contact information for Bob Smith.

<div>
My name is Bob Smith but people call me Smithy. Here is my home page: 
<a href="http://www.example.com">www.example.com</a>.
I live in Albuquerque, NM and work as an engineer at ACME Corp.
</div>

Here is the same HTML marked up with RDFa.

<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Person">
  My name is <span property="v:name">Bob Smith</span>, 
  but people call me <span property="v:nickname">Smithy</span>.
  Here is my homepage: 
  <a href="http://www.example.com" rel="v:url">www.example.com</a>.
  I live in Albuquerque, NM and work as an <span property="v:title">engineer</span>
  at <span property="v:affiliation">ACME Corp</span>.
</div>

Here's how the 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, product, 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:Person" indicates that the marked-up content represents a Person. The typeof property name is prefixed with v: (typeof="v:Person")
  • Each property of the person (such as the name and nickname) is labeled using property. The property name is prefixed with v: (<span property="v:nickname">).
  • To indicate a URL, use rel instead of property, like this: <a href="http://www.example.com" rel="v:url">www.example.com</a>. Be sure to prefix with v. "rel" is used to convey the relationship between two entities—in this case, a Person entity and a webpage entity.

Nested items

The example above shows contact information about Bob Smith. It includes his address, but nothing to indicate the relationship between Bob and that address.

It is common for one information type to include another. In this case, we want to include Bob's Address information (typeof="v:Address") in the typeof="v:Person" entity. Here, we use rel to indicate a relationship between Bob (the entity v:Person) and his address (the entity v:Address). Then, we include <span typeof="v:Address"></span> to include the actual address entity.

<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Person">
   My name is <span property="v:name">Bob Smith</span>, 
   but people call me <span property="v:nickname">Smithy</span>.
   Here is my homepage: 
   <a href="http://www.example.com" rel="v:url">www.example.com</a>.
   I live in 
   <span rel="v:address">
      <span typeof="v:Address">
         <span property="v:locality">Albuquerque</span>, 
         <span property="v:region">NM</span>
      </span> 
   </span>
   and work as an <span property="v:title">engineer</span>
   at <span property="v:affiliation">ACME Corp</span>.
</div>

For more examples, see Nested items.

Non-visible content

In general, Google won't display content that is not visible to the user. In other words, don't show content to users in one way, and use hidden text to mark up information separately for search engines and web applications. You should mark up the text that actually appears to your users when they visit your web pages.

However, in some situations it can be valuable to provide search engines with more detailed information, even if you don't want that information to be visible to the people who visit your page. For example, providing the latitude and longitude of a venue can help Google ensure that it is correctly mapped; providing the date of an event in ISO date format can help ensure that it appears correctly in search results.

In this case, you can use the content attribute to indicate that the rich snippets parser should use the attribute value to find the start date of the event.

<span property="v:dtstart" content="2009-10-15T19:00-08:00">15 October 2009, 7PM</span>

For specific vocabulary and examples, see:

To check your markup, use the structured data testing tool.