Skip to content

Mark up with RDFa Lite

Reference

RDFa Lite is a small, easy to learn subset of RDFa that covers most structured data needs. It uses a handful of attributes that attach vocabulary meaning to existing HTML.

The core attributes

  • vocab sets the default vocabulary for descendant elements, for example https://schema.org/.
  • typeof declares the type of the current item.
  • property names a property of the current item.
  • resource assigns an identifier to an item so it can be referenced.

Steps

  1. Set the vocabulary and type. Add vocab and typeof to the container element.
html
<div vocab="https://schema.org/" typeof="Movie">
  <h1 property="name">Avatar</h1>
  <span property="director">James Cameron</span>
  <span property="genre">Science fiction</span>
</div>
  1. Add properties. Mark each value with property. The element content becomes the value, except for a and img where the href or src is used.

  2. Nest items with typeof. A property whose value is an entity gets a nested element with its own typeof.

html
<div vocab="https://schema.org/" typeof="Product">
  <span property="name">Executive Anvil</span>
  <div property="offers" typeof="Offer">
    <span property="price">119.99</span>
    <meta property="priceCurrency" content="USD" />
  </div>
</div>
  1. Use content for machine values. As with Microdata, use the content attribute when the readable text and the machine value differ.

Done when

  • The container declares both vocab and typeof.
  • Each value carries a property attribute.
  • Validation confirms the item and its properties.

Notes

  • RDFa Lite is a good choice when you are already familiar with RDFa or need the additional expressivity of the full RDFa standard later.
  • For greenfield projects, JSON-LD is usually simpler to maintain.