Advanced20 min read

Structured Data & Microdata

Learn how to add structured data to your HTML using Schema.org microdata and JSON-LD to help search engines understand your content and generate rich results.

What is Structured Data?

Structured data is a standardised way to describe the content of a page so that search engines, social platforms, and other machines can understand it.

For example, a product page might contain a title, price, rating, and availability. Humans can read these from the page layout. Structured data makes this information machine-readable so Google can display rich results — star ratings, price ranges, FAQ accordions, recipe cards, and more.

The most widely used vocabulary is Schema.org, maintained jointly by Google, Microsoft, Yahoo, and Yandex. It defines types like Article, Product, Person, Organization, Event, Recipe, and hundreds more.

Microdata: HTML-Embedded Structured Data

Microdata is a set of HTML attributes that annotate your existing markup:

Key attributes

AttributePurpose
itemscopeCreates a new item (like opening a JSON object)
itemtypeSpecifies the Schema.org type (URL)
itempropNames a property of the item
html
<article itemscope itemtype="https://schema.org/Article">
  <h1 itemprop="headline">Understanding Microdata</h1>
  <p>By <span itemprop="author">Jane Doe</span></p>
  <time itemprop="datePublished" datetime="2025-06-15">June 15, 2025</time>
  <p itemprop="description">Learn how to add structured data to HTML.</p>
</article>

Microdata is woven into the existing HTML — you do not need to duplicate content. This makes it easy to maintain since the structured data and the visible content stay in sync.

JSON-LD: The Preferred Format

JSON-LD (JSON for Linked Data) is Google's recommended format. Instead of annotating HTML elements, you place a separate <script> block with the structured data:

html
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "Understanding Microdata",
  "author": {
    "@type": "Person",
    "name": "Jane Doe"
  },
  "datePublished": "2025-06-15",
  "description": "Learn how to add structured data to HTML."
}
</script>

Advantages of JSON-LD

  • Decoupled from HTML — does not clutter your markup.
  • Easy to generate dynamically (server-side or client-side).
  • Can describe things not visible on the page.
  • Preferred by Google.

When to use Microdata vs JSON-LD

  • JSON-LD — Best for most cases. Clean, easy to manage.
  • Microdata — Useful when you want the structured data tightly coupled to the visible content.

Common Schema.org Types

Frequently used types

TypeRich ResultKey Properties
ArticleNews/blog articleheadline, author, datePublished, image
ProductProduct listingname, description, offers (price, availability)
PersonKnowledge panelname, jobTitle, url, image
OrganizationCompany infoname, logo, url, contactPoint
EventEvent listingname, startDate, location, offers
FAQPageFAQ accordionmainEntity (array of Question items)
RecipeRecipe cardname, cookTime, recipeIngredient
BreadcrumbListBreadcrumb trailitemListElement (array of ListItem)

Testing structured data

  • Google Rich Results Test — Check if your structured data generates rich results.
  • Schema.org Validator — Validates against the Schema.org specification.
  • Browser DevTools — Inspect JSON-LD scripts in the Elements panel.

Both Formats in Practice

html
<!-- MICRODATA approach: annotations on existing HTML -->
<article itemscope itemtype="https://schema.org/Article">
  <h1 itemprop="headline">Getting Started with HTML</h1>
  <p>By <span itemprop="author">Jane Doe</span></p>
  <time itemprop="datePublished" datetime="2025-06-15">June 15, 2025</time>
  <p itemprop="articleBody">HTML is the foundation of every web page...</p>
</article>

<!-- JSON-LD approach: separate script block -->
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "Getting Started with HTML",
  "author": {
    "@type": "Person",
    "name": "Jane Doe"
  },
  "datePublished": "2025-06-15",
  "description": "HTML is the foundation of every web page."
}
</script>

What is the main advantage of JSON-LD over Microdata?

Ready to practice?

Create your free account to access the interactive code editor, run challenges, and track your progress.