Microformats are a set of agreed class names that you add to ordinary HTML so that software can pick out people, organizations, blog posts, events, reviews and other things on a page. Put class="h-card" on a contact block, label the name and link inside it, and any microformats parser can read it as a contact card.
They come from a community project, microformats.org, which launched on June 20, 2005. The current version is microformats2, often shortened to mf2. It replaces the older "classic" microformats, such as hCard and hReview, that you may still find on old sites.
How the class names work
Every microformats2 class name has a prefix that says what kind of thing it marks:
| Prefix | Marks | Example |
|---|---|---|
h- |
The item itself (the root) | h-card, h-entry, h-event |
p- |
A plain-text property | p-name, p-org |
u- |
A URL property | u-url, u-photo |
dt- |
A date or time | dt-published, dt-start |
e- |
A property that keeps its HTML | e-content |
A full contact card looks like this:
<div class="h-card">
<img class="u-photo" src="/images/jane.jpg" alt="Jane Doe">
<a class="p-name u-url" href="https://janedoe.example">Jane Doe</a>
<span class="p-org">Example Running Club</span>
</div>
The simplest case needs only the root class. <a class="h-card" href="https://janedoe.example">Jane Doe</a> already gives a parser a name and a URL, because microformats2 infers the name, URL and photo from common markup.
A parser turns the markup into JSON, a standard shape any program can use. Because the labels are just class names on content that's already visible, the data and the page can't drift apart.
Common vocabularies
The microformats2 vocabularies include:
- h-card for people and organizations
- h-entry for blog posts, notes, articles, comments and photos
- h-event for events
- h-review and h-review-aggregate for reviews
- h-product, h-recipe, h-resume, h-adr (addresses) and h-geo (coordinates)
Alongside these are rel values that sit on links, the best known being rel="me".
Where microformats are used today
The IndieWeb. People who run their own websites and connect them to each other use h-card and h-entry, so that a post, its author and its replies can be read by other sites and tools. The microformats project points newcomers to indieweb.org.
Proving you own a profile. rel="me" marks a link between two pages about the same person. Mastodon uses it to verify profile links: if your Mastodon profile lists your website and that site links back to your profile with rel="me", the link gets a verification checkmark. The link must use HTTPS and sit in the page's HTML, not added by JavaScript or inside an iframe.
<a href="https://social.example/@janedoe" rel="me">Find me on Mastodon</a>
Parsers and tools. Production parsers exist for many programming languages, so a site can read the microformats on another page without any special agreement between the two.
Microformats and SEO
Microformats don't help you get rich results in Google. Google's documentation lists three supported formats for structured data: JSON-LD, Microdata and RDFa. Microformats aren't among them. Google Search Central
If you want rich results, use the schema.org vocabulary in JSON-LD, which Google recommends, or in microdata. The two approaches can live on the same page: keep your h-card and h-entry for the IndieWeb and add JSON-LD for search engines.
| Microformats | Microdata | JSON-LD | |
|---|---|---|---|
| Written as | Class names on visible HTML | Attributes on visible HTML | A separate script block |
| Vocabulary | Its own (h-card, h-entry and so on) | Usually schema.org | Usually schema.org |
| Google rich results | No | Yes | Yes, recommended |
Even without rich results, microformats do what semantic HTML does: they make the meaning of your content explicit to any program that reads it. For the bigger picture, see structured data.