HTML Microdata: Attributes, Structured Data, and Examples
What is HTML Microdata: Attributes, Structured Data, and Examples? HTML Microdata is a specification used to embed structured metadata directly within existing HTML elements. Supported by major search engines through Schema.org...
What is HTML Microdata and how does Schema.org markup unlock Google Rich Snippets?
Explanation & In-Depth Details
2) The Core Microdata Attributes:
- itemscope: Declares that the enclosed HTML element represents a distinct structured item.
- itemtype: Specifies the Schema.org vocabulary URL defining the item (e.g. itemtype="https://schema.org/Product").
- itemprop: Annotates a specific property of that item (e.g. itemprop="name", itemprop="price").
3) Common Schema Types:
- Organization & LocalBusiness: Address, phone number, logo, opening hours.
- Product & Offer: Price, currency, availability, SKU, brand.
- Article: Headline, author, datePublished, publisher.
- Review & Rating: Reviewer name, reviewRating, ratingValue (displays star ratings in Google SERP).
4) Microdata vs JSON-LD: While Microdata annotates inline HTML markup directly, JSON-LD (JavaScript Object Notation for Linked Data) embeds structured data inside a <script type="application/ld+json"> block in the <head>. Both are fully supported by Google.
5) Testing Structured Data: Google provides the Rich Results Test and Schema Markup Validator to verify syntax before deploying to production.
Code Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Schema.org Microdata Showcase</title>
</head>
<body>
<h2>Product Showcase with Microdata</h2>
<!-- Product Structured Data Item -->
<article itemscope itemtype="https://schema.org/Product" style="border: 1px solid #cbd5e1; padding: 20px; border-radius: 8px; max-width: 450px;">
<h3 itemprop="name">Ultra-Light Carbon Mechanical Keyboard</h3>
<img itemprop="image" src="https://via.placeholder.com/300x200" alt="Keyboard Graphic" width="300" height="200">
<p itemprop="description">Professional wireless mechanical keyboard with custom tactile switches.</p>
<!-- Nested AggregateRating -->
<div itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating">
Rated <span itemprop="ratingValue">4.9</span>/5 based on
<span itemprop="reviewCount">128</span> customer reviews.
</div>
<!-- Nested Offer / Pricing Item -->
<div itemprop="offers" itemscope itemtype="https://schema.org/Offer" style="margin-top: 10px; font-weight: bold;">
Price: <span itemprop="priceCurrency" content="USD">$</span><span itemprop="price">149.99</span>
<link itemprop="availability" href="https://schema.org/InStock"> (In Stock)
</div>
</article>
</body>
</html>Interview Question & Tips
A1: Rich Results are enhanced search listings displaying review star ratings, recipe cooking times, product prices, or FAQ dropdown accordions directly on Google SERPs. Microdata provides the explicit machine-readable metadata that generates these cards.
Q2: How does Microdata differ from JSON-LD?
A2: Microdata weaves structured data directly into the user-facing HTML tags via attributes (itemprop). JSON-LD separates the structured data entirely into a JSON script block in the <head>. Google officially recommends JSON-LD for ease of maintenance.
Q3: Can an itemprop attribute be placed on a <meta> or <link> tag inside the <body>?
A3: Yes! When data should be machine-readable by search engines but not visible to human readers (such as ISO dates or currency codes), you can use <meta itemprop="..."> or <link itemprop="..."> inside the itemscope container.
Best Practices
This study reference for HTML Microdata: Attributes, Structured Data, and Examples is curated and verified against recognized curriculum benchmarks, peer-reviewed textbooks, and official technical documentation: