Appearance
Mark up with Microdata
ReferenceMicrodata adds structured data inline using HTML attributes. It is useful when you want the structured data to live directly on the visible elements of the page.
The three core attributes
- itemscope declares that the element and its descendants describe one item.
- itemtype names the type of that item using a vocabulary identifier such as
https://schema.org/Movie. - itemprop names a property of the current item.
Steps
- Wrap the item. Add
itemscopeanditemtypeto the container element.
html
<div itemscope itemtype="https://schema.org/Movie">
<h1 itemprop="name">Avatar</h1>
<span>Director:
<span itemprop="director">James Cameron</span>
</span>
<span itemprop="genre">Science fiction</span>
<a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">Trailer</a>
</div>Add properties. Mark each value with
itemprop. The text content of the element becomes the value.Use nested items for complex values. When a property value is itself an entity, give that element its own
itemscopeanditemtype.
html
<div itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating">
Rated <span itemprop="ratingValue">4</span> based on
<span itemprop="ratingCount">25</span> reviews.
</div>- Handle hidden machine values with meta. When the human readable value differs from the value a machine needs, use a
metaelement with acontentattribute. Use this sparingly.
html
<div itemprop="reviews" itemscope itemtype="https://schema.org/AggregateRating">
<meta itemprop="ratingValue" content="4" />
<meta itemprop="bestRating" content="5" />
Based on <span itemprop="ratingCount">25</span> user ratings
</div>Done when
- Every value that search engines should read is wrapped in an
itemprop. - Nested entities have their own
itemscopeanditemtype. - Validation reports the expected item and properties.
Notes
- For links, the
itempropvalue comes from thehrefattribute of anaelement or thesrcof an image. - Microdata works well when the structured data closely tracks the visible content. For most modern sites, JSON-LD is easier to maintain.