Sub topic 15
How Microdata and RDFa differ
JSON-LD is not the only way to publish schema.org data. Microdata and RDFa put the same vocabulary directly into HTML attributes. This chapter assumes you can read HTML attributes and nested elements, and that you know how JSON-LD uses @type, nested objects, and @id. You will learn how the two older syntaxes work, how they differ from JSON-LD and from each other, and when you still need to deal with them.
One vocabulary, three syntaxes
schema.org defines types such as Article and properties such as headline. It does not define a file format. A syntax is only a way of writing statements like "this page has an Article, and its headline is X".
- JSON-LD keeps the statements in a separate
scriptelement. The visible HTML is not touched. - Microdata adds attributes to the HTML elements that already show the content.
- RDFa (Resource Description Framework in Attributes) also adds attributes to existing elements, using a different set of attribute names.
A parser turns each syntax into the same underlying structure: entities, properties, and values. Google and other consumers that support all three can therefore read equivalent markup the same way. Google recommends JSON-LD, mainly because it is easier to maintain.
Microdata
Microdata is defined in the WHATWG HTML Living Standard. It uses a small set of attributes:
itemscopestarts a new item (an entity).itemtypegives the type as a full URL, such ashttps://schema.org/Article.itempropnames a property of the nearest enclosing item.itemidgives the item a global identifier (a URL).itemreflets an item pull in properties from elements outside its own subtree.
Here is the Article from the JSON-LD chapters written as Microdata:
<article itemscope itemtype="https://schema.org/Article">
<h1 itemprop="headline">How to Brew Cold Coffee</h1>
<time itemprop="datePublished" datetime="2026-03-14T08:00:00+00:00">March 14, 2026</time>
<img itemprop="image" src="https://example.com/images/cold-coffee.jpg" alt="A glass of cold coffee">
<p>By
<span itemprop="author" itemscope itemtype="https://schema.org/Person">
<a itemprop="url" href="https://example.com/authors/ana"><span itemprop="name">Ana Torres</span></a>
</span>
</p>
</article>Nesting works through the HTML tree. The span with itemprop="author" and its own itemscope becomes the nested Person. The name and url properties then belong to that Person, not to the Article.
Where Microdata reads its values
The value of a property depends on the element that carries itemprop:
| Element | Value used |
|---|---|
| `meta` | the `content` attribute |
| `a`, `area`, `link` | the `href` attribute |
| `img`, `audio`, `video`, `source`, `iframe` | the `src` attribute |
| `time` | the `datetime` attribute |
| `data`, `meter` | the `value` attribute |
| anything else | the element's text content |
This table explains why the Offer in a product page often needs invisible helper elements. The price as displayed, such as "€39.90", is not a clean machine value, so you separate the two:
<div itemprop="offers" itemscope itemtype="https://schema.org/Offer">
<meta itemprop="priceCurrency" content="EUR">
<span itemprop="price" content="39.90">€39.90</span>
<link itemprop="availability" href="https://schema.org/InStock">
<a itemprop="url" href="https://example.com/products/kettle">Buy now</a>
</div>The meta and link elements are not displayed. That is fine for values the page already communicates in another form, but it is the first place where markup and visible content can drift apart.
RDFa
RDFa 1.1 is a W3C Recommendation. It comes from the RDF world, so it can express more than schema.org alone. For schema.org markup you normally use the small subset called RDFa Lite, which has five attributes:
vocabsets the default vocabulary, such ashttps://schema.org/. Names that follow are resolved against it.typeofdeclares the type of a new entity.propertynames a property.resourcegives an identifier or an object value as a URL.prefixdefines short prefixes for additional vocabularies.
The same Article in RDFa:
<article vocab="https://schema.org/" typeof="Article">
<h1 property="headline">How to Brew Cold Coffee</h1>
<time property="datePublished" content="2026-03-14T08:00:00+00:00">March 14, 2026</time>
<img property="image" src="https://example.com/images/cold-coffee.jpg" alt="A glass of cold coffee">
<p>By
<span property="author" typeof="Person">
<a property="url" href="https://example.com/authors/ana"><span property="name">Ana Torres</span></a>
</span>
</p>
</article>Compare this with the Microdata version:
vocabis set once, so types and properties use short names instead of full URLs.typeofon an element that is also apropertycreates a nested entity. The Microdata equivalent needs two attributes,itempropplusitemscope itemtype.contentoverrides the visible text on any element. Microdata only allows this onmeta, plus a few specific attributes such asdatetimeandvalue.
RDFa also has about and resource for naming an entity, and it can describe things that are not in the element tree. This makes it more flexible than Microdata, and also easier to misuse.
Comparing the three
| Aspect | JSON-LD | Microdata | RDFa |
|---|---|---|---|
| Where it lives | A separate `script` block | Attributes on visible elements | Attributes on visible elements |
| Declare a type | `"@type"` | `itemscope` + `itemtype` | `typeof` |
| Name a property | JSON key | `itemprop` | `property` |
| Identifier | `@id` | `itemid` | `resource` or `about` |
| Link to an entity elsewhere | `{ "@id": "..." }` | `itemref`, or repeat the item | `resource` |
| Vocabulary mixing | `@context` can define terms | Weak, one `itemtype` per item | Strong, via `vocab` and `prefix` |
| Specification | W3C Recommendation | WHATWG HTML Living Standard | W3C Recommendation |
| Effect of a template change | Usually none | Can break the markup | Can break the markup |
The main practical difference is coupling. Microdata and RDFa are tied to the structure of the visible HTML. If a designer wraps the price in another div, or moves the author byline out of the article, the entity tree changes silently. JSON-LD does not depend on layout, so it is easier to generate from data and to test.
Gotchas
- Linking is awkward. JSON-LD's
@graphlets you define an Organization once and refer to it with@id. In Microdata you either nest a full copy of the Organization wherever it is needed, or useitemrefanditemid. Duplicates tend to drift apart. - Do not mix syntaxes for the same entity. If a page has JSON-LD for the Product and Microdata for the same Product, a parser can see two Products. Conflicting prices or names then become a validation problem. Pick one syntax per entity.
- Hidden values hide errors.
metaandcontentvalues are invisible to users. Search engine guidelines require that markup describes content that visitors can see, so keep hidden values to cases like currency codes and machine-readable dates. - Scope mistakes are easy. In Microdata, a stray
itemscopecaptures everyitempropinside it. A missing one attaches properties to the wrong entity. The output looks fine in a browser, so use a validator to check the extracted structure. - Existing markup may be generated by a theme or plugin. Check the page source before adding JSON-LD. Add it only if the existing markup is incomplete, and then remove the overlapping part.
When to choose which
Use JSON-LD for new work. It is separate from the layout, easy to generate (see the generation chapter), and the syntax Google recommends. Keep Microdata or RDFa when a content management system already emits it correctly and replacing it brings no benefit, or when your organization uses RDFa to publish other RDF vocabularies on the same pages. When you migrate, convert one page template at a time, check the result in a validator, and remove the old attributes in the same release so the two do not coexist.
Exercise
A product page contains <div itemscope itemtype="https://schema.org/Product"> with <span itemprop="name">Kettle</span> inside. A developer adds <div itemscope itemtype="https://schema.org/Offer"><span itemprop="price" content="39.90">€39.90</span></div> inside the Product, without an itemprop on the Offer div. What does the parser find, and how do you fix it?
Show answer
The Offer becomes a separate item that is nested in the markup but not connected to the Product through any property. The Product has no offers value. Fix it by adding itemprop="offers" to the Offer div, so the attributes read itemprop="offers" itemscope itemtype="https://schema.org/Offer". The RDFa equivalent is property="offers" typeof="Offer".
Exercise
Why does Microdata use <meta itemprop="priceCurrency" content="EUR">, and what is the risk of this pattern?
Show answer
The meta element supplies a machine-readable value that has no clean visible form, such as a currency code. The risk is that the value is invisible. If the page later changes its displayed currency and nobody updates the meta element, the markup no longer matches the visible content, which breaks search engine guidelines.