The HTML itemref attribute
Quick answer
The HTML itemref attribute lets a microdata item pull in properties from elements elsewhere in the document by referencing their id values. It is set on the element that has itemscope.
Overview
Normally a microdata item's properties must live inside the element that has itemscope. The itemref attribute relaxes that: it lists the id values of other elements whose itemprop properties should be added to the item.
This is useful when the markup you want to annotate is scattered across the page and you cannot wrap it all in one container. List the ids separated by spaces.
Syntax
<div itemscope itemtype="https://schema.org/Person" itemref="job">
<span itemprop="name">Ada Lovelace</span>
</div>
<p id="job"><span itemprop="jobTitle">Mathematician</span></p>
Values
| Value |
|---|
| A space-separated list of element id values. |
Example
<div itemscope itemtype="https://schema.org/Person" itemref="role">
<span itemprop="name">Ada Lovelace</span>
</div>
<p id="role"><span itemprop="jobTitle">Mathematician</span></p>
Best practices
Frequently asked questions
What does the itemref attribute do?
Specifies the list of element id's with additional properties.
What is HTML microdata?
Should I use microdata or JSON-LD?
Both work. JSON-LD keeps structured data in one script block and is often easier to maintain; microdata annotates the visible markup directly.
Is itemref a global attribute?
Yes — it is a global attribute, so it can be set on any HTML element (it is a global attribute).