References

Beginner-friendly references for web development, with live, editable examples.

The HTML itemid attribute

Global attribute Works on every element All modern browsers
In short

The HTML itemid attribute gives a microdata item a globally unique identifier, expressed as a URL. It is used together with itemscope and itemtype, for vocabularies whose types support a unique ID.

Overview

The itemid attribute attaches a stable, globally unique identifier (written as a URL) to a microdata item. It lets different pages or items refer to the same underlying thing (a specific book, product or person), which some schema.org vocabularies use.

It is only meaningful on an element that already has both itemscope and an itemtype whose definition supports global identifiers.

Syntax

<div itemscope itemtype="https://schema.org/Book" itemid="urn:isbn:0-330-25864-8"> … </div>

Values

Value
A URL (or URN) that uniquely identifies the item.

Example

Live example
<div itemscope itemtype="https://schema.org/Book" itemid="urn:isbn:978-0131103627">
  <span itemprop="name">The C Programming Language</span>
</div>

Best practices

  • Write itemid as an absolute URL. A relative value is resolved against the page's base URL, so identical markup on two pages can yield two different identifiers for the same thing.
  • Check your vocabulary's rules before two items share one itemid. HTML leaves it to each vocabulary to say whether duplicates may exist, on one page or across pages, and how to handle them.
  • An itemid is not an id. The id attribute names one element within its document, and itemref lists those ids, while itemid gives the item a global identifier that items on other pages can relate to.
  • An item used as a property value, like a product's manufacturer, takes an itemid on its own element. Whether that's allowed depends on its own itemtype, so check that this vocabulary supports global identifiers too.

Frequently asked questions

What does the itemid attribute do?
Specifies the unique item id.
What is HTML microdata?
A way to mark up structured data inline using itemscope, itemprop and related attributes so machines can read it.
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.
What happens if itemid can't be parsed as a URL?
An itemid that fails URL parsing gives the item no global identifier, as if itemid were missing.