HTML5
HTML itemid Attribute
The itemid attribute is part of HTML5 microdata, a way to embed machine-readable structured data in your HTML. itemid assigns a global, unique identifier (usually a URL) to an item, so search engines and other tools can reference that exact entity.
What is Microdata?
Microdata annotates ordinary HTML with attributes that describe the meaning of content. Search engines read this structured data to show rich results (star ratings, prices, book details). The core microdata attributes are itemscope, itemtype, itemprop, and itemid.
| Attribute | Purpose |
|---|---|
| itemscope | Declares that an element and its descendants form one item |
| itemtype | A URL to the vocabulary defining the item (e.g. schema.org type) |
| itemid | A global unique identifier (URL) for the specific item |
| itemprop | Names a property of the item and pairs it with a value |
When is itemid Valid?
itemid can only be used on an element that ALSO has both itemscope and an itemtype whose vocabulary supports global identifiers. Without itemscope and itemtype, itemid has no meaning.
Example Using itemid
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Microdata itemid Demo</title>
</head>
<body>
<div itemscope
itemtype="https://schema.org/Book"
itemid="urn:isbn:978-0141036144">
<h1 itemprop="name">Nineteen Eighty-Four</h1>
<p>Author: <span itemprop="author">George Orwell</span></p>
<p>ISBN: <span itemprop="isbn">978-0141036144</span></p>
</div>
</body>
</html>Here the <div> is one item (itemscope). Its type is a schema.org Book (itemtype). itemid gives that book a globally unique identity via its ISBN URN, and each itemprop describes a property of the book.
Key Takeaways
- itemid provides a global unique identifier for a microdata item.
- It must appear with itemscope and a supporting itemtype.
- The value is typically a URL or URN.
- Microdata helps search engines produce rich results.
