What is the itemprop attribute in HTML Microdata?
guide // , 4 min read, by Darthwares
The itemprop attribute is an HTML global attribute used to label properties on an item within Microdata structured data. It pairs with itemscope and itemtype attributes to map page content to a vocabulary like Schema.org. Structured data is a standardized format for classifying content directly within your HTML markup.
On this page // 5 sections
The short version
- The itemprop attribute labels properties on HTML elements as name-value pairs.
- Microdata uses itemscope to create an item container and itemtype to specify a vocabulary URL.
- Properties can nest inside each other by adding itemscope to an element that has an itemprop attribute.
- Search engines like Google support the Schema.org vocabulary for structured data rich results.
What is the itemprop attribute?
The itemprop global attribute adds name-value pairs to HTML elements inside Microdata markup. Introduced with HTML5, Microdata provides a set of tags to include structured data in HTML documents. Every HTML element can have an itemprop attribute specified. Each name-value pair creates a property, and a collection of one or more properties forms an item. To add a property to an item, you place the itemprop attribute on one of the descendants of the item container. An item can also have multiple properties that share the exact same name with different values.
How do itemscope and itemtype work with itemprop?
The itemprop attribute requires a defined scope and vocabulary context to function correctly. MDN Web Docs explains that itemscope is a boolean global attribute defining the metadata scope. Adding itemscope to an HTML element creates a new item container for associated name-value pairs. Every HTML element may have an itemscope attribute specified. MDN Web Docs also notes that an element with itemscope that lacks an itemtype must have an associated itemref attribute.
To define the item type, specify the itemtype attribute immediately after itemscope on the exact same element. WHATWG HTML Standard rules state that itemtype must not be specified on an element without an itemscope attribute. The itemtype attribute holds the valid URL of a vocabulary that defines what properties are valid in that scope.
How does Schema.org connect to HTML Microdata?
Schema.org provides the vocabulary used with Microdata, RDFa, or JSON-LD formats to add structured information to web pages. MDN Web Docs documents that Google and other major search engines support the Schema.org vocabulary. Structured data classifies page content, such as ingredients, cooking time, temperature, and calories on a recipe page. Google Search Central notes that while most search structured data relies on Schema.org, you must rely on Google Search Central documentation as definitive for Google Search behavior.
Google documents that structured data must include all required properties for an object to be eligible for enhanced search displays known as rich results. Microdata allows nested groups of name-value pairs directly in your markup parallel to existing content. You can nest items by putting an itemscope attribute on an element that declares an itemprop property. If a property value is a URL, it must be specified using a URL property element. When identifying items uniquely, the itemid attribute can only be specified on an element that has both itemscope and itemtype attributes.
How do you diagnose Microdata and itemprop errors?
Validating Microdata structure ensures search engines can extract named properties correctly. Issues often stem from missing scope declarations, invalid attribute placement, or omitted required fields.
- 01Check that every element with an itemtype attribute also includes an itemscope attribute on the exact same element.
- 02Ensure that any itemscope element missing an itemtype includes a valid itemref attribute.
- 03Verify that all required properties defined in documentation are present, and that any property whose value is a URL uses a URL property element.
- 04Confirm that itemid is only applied to elements containing both itemscope and itemtype.
| Symptom | Check | Fix |
|---|---|---|
| itemtype attribute is ignored | Check if itemscope attribute is present on the same HTML element | Add the itemscope attribute to the element containing itemtype |
| itemscope scope lacks vocabulary context | Check whether itemtype or itemref is declared on the element | Add a valid vocabulary URL with itemtype or specify itemref |
| Ineligible for rich search results | Check if required object properties are missing or URL properties are invalid | Include all required itemprop properties and use URL property elements for link values |
| itemid attribute fails validation | Check if both itemscope and itemtype are present on the element | Ensure itemid is placed only on elements with both itemscope and itemtype |
Common questions
What is the purpose of the itemprop attribute?
The itemprop global attribute adds name-value pairs to HTML elements within Microdata structured data to define properties of an item.
Can an HTML element have an itemtype attribute without itemscope?
No. WHATWG HTML Standard rules specify that itemtype must not be placed on elements that do not have an itemscope attribute present.
How do you handle property values that are URLs in Microdata?
MDN Web Docs specifies that if a property value is a URL, the property must be specified using a URL property element.
Does Google support Schema.org vocabulary with Microdata?
Yes. MDN Web Docs notes that Google and other major search engines support Schema.org vocabulary for structured data markup.
Primary sources and further reading
This article was researched and written by an AI model and published automatically. It was written from sentences that were checked to appear on the pages below, but a person has not reviewed the text. If something is wrong, tell us at chibivikramathithan@darthwares.com and we will correct it.