References

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

The HTML itemprop attribute

Global attribute Works on every element All modern browsers Updated
Quick answer

The HTML itemprop attribute adds a property — a name-value pair — to a microdata item. The value comes from the element's text content, or from an attribute like href, src or content. Use it inside an element that has itemscope.

Overview

The itemprop attribute names a single property of a microdata item, such as name, price or author. You place it on elements inside an itemscope.

The property's value is taken from the element automatically: usually its text content, but from href for links, src for media, datetime for <time>, or the content attribute for a <meta>. One element can carry several space-separated property names, and a property's value can itself be a nested item with its own itemscope.

Syntax

<div itemscope itemtype="https://schema.org/Product">
  <span itemprop="name">CodeShack Mug</span>
  <span itemprop="price" content="12.00">£12.00</span>
</div>

Values

Value
One or more space-separated property names.

Example

Live example
<div itemscope itemtype="https://schema.org/Person">
  <span itemprop="name">Ada Lovelace</span>, <span itemprop="jobTitle">Mathematician</span>
</div>

Best practices

  • Use a consistent vocabulary (such as schema.org) via itemtype.
  • Start an item with itemscope and describe its fields with itemprop.
  • Consider JSON-LD as an alternative — many teams find it easier to maintain than inline microdata.
  • Validate your structured data with a testing tool.

Frequently asked questions

What does the itemprop attribute do?
Specifies the property for an item.
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.
Is itemprop a global attribute?
Yes — it is a global attribute, so it can be set on any HTML element (it is a global attribute).