Microdata

Frontend SELF EN
Level 11, Lesson 3
Available

9.1 What is Microdata?

Microdata (structured data) is a way to add metadata to HTML documents to better interpret the content of webpages by search engines and other services. It's used to describe different entities and their relationships on a webpage, which helps improve page visibility in search results and offers extra features like rich snippets.

Microdata are structured data added to the HTML code of a page. It provides search engines with extra info about the page content, like content type, author, publication date, rating, and other data.

Structured data consists of two parts: a vocabulary — which terms describe your entities — and a syntax — how those terms are physically written into HTML. These are different levels, and it is worth not mixing them up.

The vocabulary is Schema.org: a shared set of types (Article, Product, Event, Organization and others) and their properties. Schema.org was founded by Google, Microsoft, Yahoo and Yandex, is developed by an open community, and is understood by all major search engines.

The syntax is the way you write it down. The very same Schema.org vocabulary can be expressed in three different ways:

  • JSON-LD: the data sits in a separate block inside <script type="application/ld+json"> and does not get mixed into the markup. A W3C standard; this is the one Google recommends.
  • Microdata: the itemscope, itemtype, itemprop attributes are added right onto HTML elements. Defined in the HTML Living Standard.
  • RDFa (RDFa Lite 1.1): the vocab, typeof, property attributes — also right on HTML elements. A W3C Recommendation.

Besides Schema.org there are other vocabularies for specific jobs — for example Open Graph (link previews in social networks) and microformats2. In this lecture we work with Schema.org.

9.2 Schema.org

Schema.org is a vocabulary of data types and their properties developed for structuring data on web pages. It supports a bunch of data types, like articles, events, organizations, products, and so on.

Examples of using Schema.org

Article:

HTML (original page, no markup)
    
      <article>
        <h1>Article Title</h1>
        <p>Author: Author Name</p>
        <p>Publication Date: January 1, 2024</p>
        <img src="https://example.com/image.jpg" alt="Example Image">
        <p>Article text...</p>
      </article>
    
  
HTML + JSON-LD (the same page with structured data)
    
      <script type="application/ld+json">
        {
          "@context": "https://schema.org",
          "@type": "Article",
          "headline": "Article Title",
          "author": {
            "@type": "Person",
            "name": "Author Name"
          },
          "datePublished": "2024-01-01",
          "image": "https://example.com/image.jpg",
          "publisher": {
            "@type": "Organization",
            "name": "Publisher",
            "logo": {
              "@type": "ImageObject",
              "url": "https://example.com/logo.png"
            }
          }
        }
      </script>
    
  

Product:

HTML (original page, no markup)
    
      <body>
        <h1>Product Name</h1>
        <img src="https://example.com/product.jpg" alt="Product Image">
        <p>Product Description</p>
        <p>Price: $29.99</p>
      </body>
    
  
HTML + JSON-LD (the same page with structured data)
    
      <script type="application/ld+json">
        {
          "@context": "https://schema.org",
          "@type": "Product",
          "name": "Product Name",
          "image": "https://example.com/product.jpg",
          "description": "Product Description",
          "sku": "0446310786",
          "offers": {
            "@type": "Offer",
            "priceCurrency": "USD",
            "price": "29.99",
            "itemCondition": "https://schema.org/NewCondition",
            "availability": "https://schema.org/InStock",
            "url": "https://example.com/product"
          }
        }
      </script>
    
  

Benefits of using Schema.org:

  1. Improved visibility: search engines can display additional data in search results (rich snippets).
  2. Better interpretation: search engines understand content better, potentially improving page ranking.
  3. Standard support: Schema.org is supported by all major search engines.

9.3 JSON-LD

JSON-LD (JavaScript Object Notation for Linked Data) is a method for encoding microdata in JSON format, inserted into a <script> tag on the page. Google recommends using JSON-LD for structured data.

Example of using JSON-LD

Organization:

HTML (original page, no markup)
    
      <body>
        <h1>Company Name</h1>
        <p>Company Description</p>
        <div>Contacts</div>
      </body>
    
  
HTML + JSON-LD (the same page with structured data)
    
      <script type="application/ld+json">
        {
          "@context": "https://schema.org",
          "@type": "Organization",
          "name": "Company Name",
          "url": "https://example.com",
          "logo": "https://example.com/logo.png",
          "contactPoint": {
            "@type": "ContactPoint",
            "telephone": "+1-800-555-1212",
            "contactType": "Customer Service"
          }
        }
      </script>
    
  

9.4 Microdata

Microdata is a structured data syntax embedded straight into HTML. Special attributes itemscope, itemtype and itemprop (plus itemid and itemref) are added to ordinary HTML elements and link them to types and properties from the Schema.org vocabulary.

Example of using Microdata

Event:

HTML + Microdata
    
      <body itemscope itemtype="https://schema.org/Event">
        <h1 itemprop="name">Event Name</h1>
        <time itemprop="startDate" datetime="2024-05-01T19:00">May 1, 2024, 7:00 PM</time>
        <div itemprop="location" itemscope itemtype="https://schema.org/Place">
          <span itemprop="name">Venue</span>
          <div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">
            <span itemprop="streetAddress">Street, Building</span>
            <span itemprop="addressLocality">City</span>
            <span itemprop="postalCode">Postal Code</span>
            <span itemprop="addressCountry">Country</span>
          </div>
        </div>
      </body>
    
  

Benefits of using microdata:

  1. Rich snippets: search engines can display enhanced snippets in search results, increasing click-through rates.
  2. Better content understanding: search engines understand content better, which might improve page ranking.
  3. Support for voice search: structured data can improve voice search results.
  4. Integration with other services: microdata enables content integration with various services like Google Knowledge Graph and others.
1
Task
Frontend SELF EN, level 11, lesson 3
Locked
Microdata
Microdata
1
Task
Frontend SELF EN, level 11, lesson 3
Locked
Microdata for an Event
Microdata for an Event
Comments (1)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
ceciliabarranco94 Level 19, CDMX, Mexico
11 April 2025
nice