17

The bottom of the Wikipedia "talk" page says that Microdata is dead, and superseded by rdfa and json-ld.

What is the difference between the formats (or value), and which one should be used?

I'm mostly interested in SEO for Google Shopping, and contact sharing.

0

1 Answer 1

19

Microdata is not dead. While Microdata will not become a W3C standard¹, it’s still part of WHATWG’s HTML Living Standard.

Differences between JSON-LD, Microdata, and RDFa

(in the context of HTML documents)

Microdata and RDFa are conceptually similar: both syntaxes define attributes that get added to your existing HTML elements.

JSON-LD is a syntax that gets added to a script element (used as data block, not as script), separately from your existing markup.

So the primary difference between Microdata/RDFa and JSON-LD is that you have to repeat the content if using JSON-LD, while you can² mark up your existing content if using Microdata/RDFa.

These three snippets convey the same structured data (a Person with a name of "Alice"):

<!-- Microdata -->

<p itemscope itemtype="http://schema.org/Person">
  Hi, I’m <span itemprop="name">Alice</span>.
</p>
<!-- RDFa -->

<p vocab="http://schema.org/" typeof="Person">
  Hi, I’m <span property="name">Alice</span>.
</p>
<!-- JSON-LD -->

<p>
  Hi, I’m Alice.
</p>

<script type="application/ld+json">
  {
   "@context": "http://schema.org",
   "@type": "Person",
   "name": "Alice"
  }
</script>

Which to use?

JSON-LD if you want to add a blob of structured data, without having to care about existing markup. Might be easier for tools that don’t support structured data (and you use other tools to generate/add it), or when copy-pasting ready-made snippets.

Microdata/RDFa if you want to make use of your existing markup (so you don’t have to duplicate the content → DRY). Might be easier if adding it by hand, or when tools already support it (like Drupal).

If deciding between Microdata and RDFa: I recommend to use RDFa instead of Microdata, primarily because of the differences outlined in this answer on Stack Overflow.

RDFa and JSON-LD are both W3C Recommendations and both are RDF serializations.


For reference: an older related answer about Microformats vs. Microdata vs. RDFa / Schema.org.

¹ At least not in the foreseeable future. https://www.w3.org/TR/microdata/ became a W3C Working Group Note in 2013 (https://www.w3.org/TR/2013/NOTE-microdata-20131029/), so it no longer gets updated/edited, and it will not become a W3C Recommendation.

² Of course Microdata/RDFa would allow to do something similar to JSON-LD: instead of marking up existing content, you could add meta/link elements that repeat the content. Bad practice, but possible.

3
  • 2
    Currently (July 2017), Google recommends unsing JSON-LD "wherever possible": developers.google.com/search/docs/guides/intro-structured-data Jul 21, 2017 at 8:11
  • Do I understand right, JSON-LD can only let you specify general info about whole page, but you can't express which exactly parts of the webpage correspond to which object in JSON-LD? Like, if you have a list of books, you can specify in JSON-LD that this page shows a list of books, but you won't be able to tell which of the books described in the JSON-LD correspond to which exactly element on the webpage? If so, Microdata/RDFa have one more important advantage: providing context to screenreaders used by blind people, but maybe I'm missing something in how JSON+LD works.
    – Klesun
    Jun 15 at 4:55
  • 1
    @Klesun: Correct, with JSON-LD, there is no native way to connect the HTML elements with the JSON-LD statements. But even with Microdata and RDFa, the HTML is just the carrier. Microdata/RDFa parsers will just extract the statements, without any coupling to the HTML. I suppose it could be conceivable for user agents (like screen readers) to use Microdata/RDFa to get more context about the HTML, but AFAIK no one does that yet, and Microdata/RDFa were not designed for this to begin with.
    – unor
    Jun 16 at 12:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.