Microformats vs RDFa vs Microdata

Warning: The microdata syntax has changed (e.g. item="foo" is now itemscope itemtype="foo") since this blog post was written. Don’t copy the examples.

I spent last weekend with my good friend Emil sketching a REST-style interface for his graph database Neo4j. One of the output formats we wanted was plain HTML for easy debugging via the browser. Wanting to enable JavaScript-based enhancements of these pages we needed a way to annotate the data to make it available to scripts. (Use by clients of the REST API should be possible, but unlikely if XML or JSON output is available.)

The three candidates were microformats, microdata and RDFa. We began with plain HTML:

  I'm Philip Jägenstedt at
  <a href="http://foolip.org/">foolip.org</a>.

The simple task at hand is to make my name and homepage machine-readable using each of these formats. What follows is a more elaborate version of the reasoning we went through while evaluating the strengths and weaknesses of each alternative.


<p class="vcard">
 I'm <span class="fn">Philip Jägenstedt</span> at   <a class="url" href="http://foolip.org/">foolip.org</a>.

Microformats are “a set of simple, open data formats”, i.e. predefined vocabularies under centralized control. In this example I’ve used the hCard microformat. One “feature” of microformats is that it is valid HTML 4.01/XHTML 1.0, which is why the class attribute is used in novel ways. Although HTML 4.01 mentions that class may be used “for general purpose processing by user agents” it’s normally only used “as a style sheet selector”, i.e. for CSS. What this means is that we are working in a single global namespace which is already polluted with all the CSS class names ever used.

The only thing that distinguishes microformats from random CSS classes is the tree structure. This structure is quite a limitation though, because it means that you have to find or make a common ancestor element to all of the data in a single hCard. For a data interchange format, it all seems insane and simply too brittle. Emil put it rather bluntly when he tweeted:

Microformats. Pile of shite that just increases our systematic technical debt.

Still, I have great respect for some of the people behind microformats and the down-to-earth philosophy. They openly state that microformats aren’t “infinitely extensible and open-ended” or “a panacea for all taxonomies, ontologies, and other such abstractions”. As microformats was never intended to solve our use case it is no surprise that it really doesn’t.

Certainly anyone can use class="foo" to mean anything they like without going through the microformats process – such data formats are cleverly called poshformats (Plain Old Semantic HTML). All things considered though, the whole approach seems outdated and I hope it won’t still be around 5 years from now. Microformats has shown the need for HTML-embedded machine-readable data, now let’s find a better solution.


To understand RDFa you first need some understanding of RDF. The RDF model is basically a somewhat roundabout way of describing graphs using subject-predicate-object triples. An example is the best way to illustrate:

RDF graph of me, my name and my homepage

This graph represents me, my name, my homepage and the relationships between them. I’m using the FOAF vocabulary because it already has the concepts of “name” and “homepage”. In N3 syntax this corresponds to these two triples:

@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> <foaf:name> "Philip Jägenstedt" .
<#me> <foaf:homepage> <http://foolip.org> .

Everything in <brackets> is a URI and because URIs tend be long prefixes are used: <foaf:name> actually means <http://xmlns.com/foaf/0.1/name&gt;. I’ve used #me to represent myself, but this should really be resolved to a full URI.

As you can see, the subject is #me in both statements. The relationships in the graph are the predicates, i.e. foaf:name and foaf:homepage. The object is either another URI or a string literal. Adding RDF triples equates to adding more nodes and relationships to the graph. This is general enough that you can model almost anything you want with it.

Back to RDFa. The “a” refers to how attributes in XHTML are used to serialize RDF:

<p xmlns:foaf="http://xmlns.com/foaf/0.1/" about="#me">
 I'm <span property="foaf:name">Philip Jägenstedt</span> at
  <a rel="foaf:homepage" href="http://foolip.org/">foolip.org</a>.

The use of XML namespaces here is a bit odd. Prefixes in XML are used on element and attribute names, but here it’s only used in the attribute value. These are actually CURIEs, another URL shortening scheme. Jeni Tennison recently wrote an excellent post about the use of prefixes in RDFa which I encourage everyone to read. I also chatted briefly with Henri Sivonen about the problems with xmlns and would recommend reading his mails on those issues.

If we return to RDFa syntax for a bit, notice how property, rel and rev are used for the exact same purpose (setting the predicate) in different contexts. The intention was probably to mimic existing practices such as rel=”next”, but the net result is just more room for confusion. While I won’t claim that it’s just too hard I certainly think it could have been simpler without loosing much expressive power.

RDFa began in the now discontinued XHTML2 WG and seems strongly rooted in the Semantic Web (now Linked Data) community and that stack of technologies and tools. It was later made into a module for XHTML 1.1, but there is no W3C-sanctioned way of embedding RDFa in plain HTML. Getting into HTML5 would guarantee RDFa’s survival in the web ecosystem, so its proponents approached the WHATWG/HTML WG suggesting that RDFa be included. There was much heated discussion, the drama of which was my sole source of entertainment for weeks at a time. I’ll again refer to Jeni’s summary of the clash of priorities and “fruitless discussion”. I particularly want to emphasize this conclusion:

It’s just not going to happen for HTML5

I don’t hate RDF(a). I can certainly see the appeal of the RDF model after taking the time to understand it. It may just be a very verbose way of describing graphs, but as a data interchange format it seems to do a good job. However, being able to express arbitrary RDF in HTML in a compact way is not an actual use case for most web developers. If it’s possible without added complexity that’s fine, but HTML is not a triplestore.


As a result of gathering use cases and other input from the big RDFa discussion, suddenly one day HTML5 microdata section sprung into existence along with a very long announcement to the WHATWG list from Ian Hickson (our editor). Within 3 hours there was a demo and not long after another. This is it:

<p item="vcard"> I'm <span itemprop="fn">Philip Jägenstedt</span> at
  <a itemprop="url" href="http://foolip.org/">foolip.org</a>.

This looks very similar to the microformats example, but the new item and itemprop attributes are used instead of class. The model used is nested groups of name-value pairs, where the name-value pairs are given by the elements with itemprop attributes. In other words, it is quite similar to a DOM tree or a JavaScript object.

There are some predefined item types (used above), but it’s possible to use either URLs (http://foolip.org/footype) or reversed DNS identifiers (org.foolip.footype) to define your own types without any risk of namespace pollution. Note however that there are no prefixes or other URL shortening schemes. I don’t think I’m crazy to suggest that services like bit.ly and tr.im have shown a way out of the “long URL” problem. If microdata gains any traction, I think communities will create vocabularies with clever shorthands like http://link.to/the/past, mr.burns or ht.ml5.

Finally, the subject attribute can be used to avoid the “common ancestor” problem we had with microformats by simply referring to the item element by id:

<p item="vcard" id="me">
   I'm <span itemprop="fn">Philip Jägenstedt</span>.
<!-- stuff -->
<a itemprop="url" subject="me"   href="http://foolip.org/">foolip.org</a>.

Microdata is quite straightforward and feels much more native to HTML than RDFa. As Jeni explains, microdata can’t express RDF triples using datatypes or XML literals. I’ll also add that using a blank node as object isn’t possible. Other than that, RDF triples can be expressed by using the about type to give the subject of the name-value (predicate-object) pair. Here’s my FOAF example from earlier:

<p item>
  <a itemprop="about" href="#me"></a>
  I'm <span itemprop="http://xmlns.com/foaf/0.1/name">
    Philip Jägenstedt</span> at
  <a itemprop="http://xmlns.com/foaf/0.1/homepage"

It is quite ugly, so if there’s any way to make it simpler I’m sure such suggestions are welcome. In general though, it seems like a better idea to use simple microdata structures and map that against a RDF vocabulary if possible. In fact, the spec already defines how to extract some RDF (and JSON) from microdata so I’m sure it’s not difficult to do.

Returning to the “browsable web” (the one I normally work with), microdata has a DOM API that browsers can implement. The prospect of JavaScript having access to the microdata on a page is so exciting that I didn’t want to wait, so I hacked up MicrodataJS to try it out. You can access my name and email in the vcard example as such:

var props = document.getItems("vcard")[0].properties;
var fn = props.namedItem("fn")[0].content;
var url = props.namedItem("url")[0].content;
alert("Name: " + fn + "; URL: " + url);

Unsurprisingly there are some issues with the API which I’ve sent feedback on and expect to be fixed to my satisfaction eventually, but the basic functionality is sound. I imagine scripts making dynamic pie charts from tables, providing page-specific autocomplete suggestions and making shiny animated SVG visualizations of the RDF graphs hidden in the tag soup…

Google is now offering to do usability testing of the microdata syntax to see if it can be improved, so if you have any suggestions be sure to bring those to the WHATWG now.


The examples I’ve used are overly simplistic and may utterly fail to show the strengths and weaknesses of each syntax. Still, this is my best effort to make sense of the issues at hand and I haven’t intentionally misrepresented any technology or community. I assume that there is much more debate to come before the dust settles on this issue and perhaps I’ll even change my mind after experimenting more with real-world implementation. I leave you with this unambiguous summary of my views:

  • Microformats, you’re a class attribute kludge
  • RDFa, HTML is not your triplestore
  • Microdata, I like you but you need more review


  • Shelley Powers wrote about RDFa and HTML5’s microdata from the perspective of the RDFa/Semantic Web community. It’s quite a different view from mine, so read that before believing my propaganda.
  • Following James Graham’s suggestion, I have registered mantic.se for fun reverse DNS identifiers like se.mantic.banana. Mostly for fun, don’t take it too seriously…
  • I misunderstood Jeni’s post about expressing RDF in microdata and have fixed that section to be more accurate.

Disclaimer: this post is the result of excess spare time and not part of my work at Opera Software. I know nothing about Opera’s plans (or lack thereof) for microformats, RDFa or microdata.

20 thoughts on “Microformats vs RDFa vs Microdata

  1. You say “As Jeni explains, it is actually possible to express any RDF triple (except those using a blank node as object!) by using the about type to give the subject of the name-value (predicate-object) pair.”

    Actually, as I tried to explain in the post you referenced, there are two other RDF-type things you can’t express in Microdata: a datatyped literal and an XML literal. So you can’t express the triple:

    <http://foolip.org/> dc:modified "2009-08-24"^^xsd:date

    Nor can you create a triple whose object is an XML structure, such as a snippet of XHTML (the body of a blog post, say).

    I’m glad that you find accessing the metadata embedded in the page using Javascript exciting — so do I! If you want to try doing so with RDFa markup you could have a look at rdfQuery, which is a kind of mix between SPARQL and jQuery.

    • You’re right of course Jeni. I read that post when you first published it, but the second time around I misunderstood the first part of your post to mean quite the opposite of the overall message. I’ve updated the post to not misrepresent you.

      On the actual subject matter, one might consider syntax like itemprop="date#org.foolip.modified", itemprop="date<org.foolip.modified>" or something like that. You’d have to make sure that it’s unambiguous if it’s a URI, reversed DNS or other token and define error handling when string can’t be parsed as the given type, of course.

  2. If all you want is an HTML dump of a JSON-like data structure, use XOXO – it defines a simple mapping of lists and dicts to HTML lists and definition lists, with some special cases for URLs.

    Using class attributes for structure isn’t a kludge; it’s what they were defined for. Microformats focus on agreeing common ones.

  3. Pingback: Bruce Lawson’s personal site  : This millenium in HTML 5 (politics)

  4. Pingback: Structured data : implementing RDFas and Microformats in web pages « AmyVarga's Blog

  5. wow. u know a lot about chinese culture. I’m from China and I love Sweden.
    I know several Swedish friends and they are so cute~

  6. Pingback: RDFa vs Microformat « Reseatch Items

  7. Is it not possable to use all 3 formats together?


    <p class="vcard" item="vcard" xmlns:foaf="http://xmlns.com/foaf/0.1/" about="#me">
      I'm <span class="fn" itemprop="fn" property="foaf:name">Philip Jägenstedt</span> at
      <a class="url" itemprop="url" rel="foaf:homepage" href="http://foolip.org/">foolip.org</a>.
  8. It’s possible, but ridiculously verbose, don’t you think? I’d also be surprised if it’s valid under any validator settings, as RDFa is opt-in and I doubt anyone writing such a validator would also include Microdata.

  9. Pingback: Are Microformats worth the effort for SEO?

  10. Pingback: Resources from last night’s PDX SemWeb talk | Ghosted Notes

  11. Pingback: Quora

  12. So I only just found this post, via your nice work on the parser.

    Interesting re the Neo4J connection – did you ever try Gremlin / Tinkerpop tools?

    I wrote up some recent experiments – http://danbri.org/words/2011/05/10/675 – it’s quite a nice way to interact with this kind of data. If we can get graph structures from microdata, that should just plug right in too…

  13. Thanks, I hadn’t seen Gremlin before. Getting RDF graphs out from microdata is already possible as you know, as long as you don’t want the predicate URI to be pretty :)

  14. :) well there’s two kinds of pretty.

    1) de-reference to something useful, eg. annotations that express basic mappings between terms, or say which properties are functional, inverse functional etc. Or multilingual labels.

    2) be really nice short URIs without loads of unnecessary clutter.

    For (1) I’d prefer microdata’s rdf mapping to use decentralised URIs directly, not point them all off at W3C. Or maybe it could be an argument to parsers? For (2) I suspect the RDF community might need to save up its pocket money and buy some nice short domain names. I’m considering using http://foaf.tv/Person as an alias for http://xmlns.com/foaf/0.1/Person for example…

  15. Maybe we can make some practical use case around schema.org, … eg. including translation and mapping data in those pages. Will investigate…

  16. Mapping amongst microdata RDFa microformat is documented by W3 at https://dvcs.w3.org/hg/htmldata/raw-file/default/ED/html-data-guide/index.html
    IMHO, microformat is generalized parseable RDFa snippet that when nested into XHTML5, note the “X”, makes XSL transformation applicable, so serving hNews as atom feed maybe left to server & consumer of content has better flexibility with regards to consumption technique.
    Search providers just needed short-hand vocabulary for simpler parsing by their crawling bots as the transformations besides updating their indexing database benefit the consumer in the content providers’ interest rather than build the search providers reputations. So they used their monopoly over consumers thereby saving on parsing effort, by putting the onus on content provider for overloading the markup with their short-hand towards SEO, viz. the overly restrictive microdata that beyond schema.org’s vocabulary serves only academic fancy.
    I dare say with regards to being restrictive, microdata is anti-OWL of sorts.

  17. In the first paragraph under microformats topic you state: class may be used “for general purpose processing by user agents”
    and then go on to add:
    in a single global namespace which is already polluted with all the CSS class names ever used.
    With the exception of using “pollution” instead of “utilisation” to insult our predecessors hard work on web semantics, Gr8 article.
    Good point is abandoning of RDFa prefix attribute and namespaces altogether in microdata makes it an uglier rendition of RDFa. Also, W3 needs to be strictly clearer that rel is not meant to substitute for property.

Comments are closed.