1. Code
  2. Web Development

Microformats: What, Why, and How

Scroll to top
Read Time: 10 min

There's a lot of data on the web. Like, a lot. But I would guess that the data most useful to the masses—such as information about people they need to contact or events they need to attend—is stored in HTML, where you can't easily get at it. So, who you gonna call? Microformats is attempting to take on the job!


Let's take this from the top. What are microformats? Off the homepage of comes this definition:

Designed for humans first and machines second, microformats are a set of simple, open data formats built upon existing and widely adopted standards.

A good start, but we need a bit more to clarify. You can find a whole list of definitions on the site, but here's the summary: microformats are a set of standards for embedding easily extractable data on your pages, using technologies you are comfortable with today. The great part about this is that you probably have content on your site right now that you could mark up with a microformat. The even greater part is that it will only take you a couple of minutes after reading this tutorial.


So why should you use microformats? What's the incentive? Well, if you're convinced that HTML should be semantic just because, then microformats will click with you. Otherwise, I'll persuade: as we noticed, the whole idea of microformats is to standardize that way data is marked up on a page, so that it can be easily extracted. Currently, there aren't a whole lot of tools that take advantage of microformats, but I think that will change. Using microformats in your work will prepare your websites for the future, when microformats will be much more widespread. Again, the website has general list of what you can do with microformats. There's already decent Firefox addon for extracting microformats; it's called Operator.

Operator FireFox AddOnOperator FireFox AddOnOperator FireFox AddOn

Then, Dan Web has created a simple JavaScript library called 'Sumo' that extracts microformats for use with JavaScript. You can also try the microformats bookmarklet.


Well, if you've gotten this far, it's obvious you and microformats were meant for each other. So let's hop right in and look at one. But before we do, here's the general structure of the microformats we'll be looking at: generally speaking, if they involve more than one element in our code, they use classes. If they are only concerned with one element, it's usually the rel attribute that's used.


hCalendar is an easy way to mark up events. We'll start with an element that declares our event:

If you have multiple events, you should wrap them in a div.vcalendar; however, it's not necessary. There are two required properties for an event: the start date (dtstart) and the summary. Let's add these:

Human-readable, eh? Not that date! You're right; although microformats are written for people first, dates are one area where it's important that computers can read it. Common convention would be to write the date with an abbr tag, in which case the title attribute would be the value for the property value:

There are other, optional properties you can add, as well. How about an end time, or a location?

Using the Operator Toolbar in Firefox, we can see that this event is on our page. We can work with it in several ways:

hCalenday in OperatorhCalenday in OperatorhCalenday in Operator

If I choose to export it to Google Calendar, it perfectly carries over the values we have set.

Google Calendar, importing hCalendarGoogle Calendar, importing hCalendarGoogle Calendar, importing hCalendar

For more about hCalendar, check out the hCalendar documentation,


Let's move on to hCard; hCard is a lot more complicated than hCalendar, but we won't get into all the details. If you want to read more later, check out the docs.

Again, we start with our root:

For hCard, there are only two required properties; the name (n) and the formatted name (fn). Usually, there are the same element.

Without going too deep, I'll note that this format implies that 'John' is the first name and 'Doe' is the last name. If you want to specify this, you can use the given-name and family-name classes:

Of course, you'll usually want to add more than just your name. You can add a nickname, photo, email address, birthday, url, telephone number, and address, just to name a few.

There are a few things to note here:

  • All the class names I've used here are the hCard properties.
  • Some properties, like url and photo, take their values from the href or src attributes, and not the text of the element.
  • Properties like tel and email can have two child properties: type and value. If only type is defined, value will be implied (as you can see in the second email address and telephone number).

Using Operator, I can export this as a vcard …

hCard in Operator

… and open it in Outlook.

hCard in OutlookhCard in OutlookhCard in Outlook

See? Everything we defined is here!


xFolk is a developing microformat for open social bookmarks. From the docs:

Lack of an open, interoperable data standard is a major issue in using social bookmarking services. An open standard would make it possible to easily collect social bookmark data and remix it to invent new services … An open standard would also make it possible to write JavaScripts that work across services as some currently do for, enabling across-the-board improvements in user experience.

To implement xFolk, start by giving each bookmark wrapper a class of 'xfolkentry':

Then, insert the link and a description, giving them classes of 'taggedLink' and 'description', respectively.

Yup, simple; I can imagine this being useful on a blog roll, or in a web roundup. Think of a tool that would let you bookmark all of these links at once.

XFN (XHTML Friends Network)

XFN is a simple way to mark up human relationships. Using the rel attribute (which is short for relationship) on your links, you define your relationship with the owner of the page you're linking to. You can have a relationship with two parties: other people or yourself (well, your other pages). It's easy to define other pages you own:

Pretty simple, eh? rel=”me” and you're done.

Relationships with other people are a bit more detailed, but no more difficult: There are six categories you can take options from: friendship, physical, professional, geographical, family, romantic. I won't list them all here (a good idea would be to try the link creator), but here are a few examples:

In the first link, you can tell from the rel attribute that I've met the owner of the page I'm linking to and that I am his friend. Next is my (hypothetical) wife, who happens to be my spouse and sweetheart, as well as someone who I have met and who inspires me. I've also met the guy next door, but he's only an acquaintance and neighbor. Finally, although my (again, hypothetical) Co-worker is a friend, notice that I've never met him; this would be described as a virtual relationship. I should point out that you shouldn't use XFN when just linking to a blog post or the like; use it when you're directly referring to a person, so there name is the text of the link, and the href goes to their home page.


VoteLinks is an interesting idea: when you link to an article, posting, product, anything, add the rev attribute. Rev? Rev is the opposite of rel; while rel describes what the linked page is to current page (like a 'friend' or a 'stylesheet'), rev describes what the current page is to the linked one. With VoteLinks, you can make your page a 'vote-for', 'vote-against', or 'vote-abstain' whatever you are linking to. So, for example:

How is this useful? Well, imagine if Google (and other search engines) took VoteLinks into account when displaying items. Currently, their system (put very basically) is the more links, the more visibility on Google. But what if most of those links were votes against the product or page? Or how about a site that crawls the web looking for VoteLinks and shows you the general popularity of pages? It's all very speculative, but it could be interesting. The problem is, a lot of people need to be using VoteLinks for them to have any effect.


Geo is very simple; it has two properties: latitude and longitude.

As we've seen before, you can use the abbr element to mask the real values. And of course, Operator recognizes these.



If you've ever released anything to the public, you know you need to put a license on it. You can give the rel attribute of a link the value of 'license' when linking to the license documentation.

What's the point? Already Yahoo Creative Commons Search and Google Usage Right's Search both use the rel='licence' attribute in their algorithms.


This is an interesting one, because every blogger tags their posts. For this microformat, simply add rel=”tag” to your tag links and be done. Now, using our Operator add-on, we can see content from other sites with the same tags. It's important to note that the name of the tag is taken from the href of the link, and not the text of the link. So in the following example …

… the tag is 'javascript' and not 'client-side scripting.'

Nettuts has implemented this microformat; but you already knew that if you have Operator!

rel-tag on Nettutsrel-tag on Nettutsrel-tag on Nettuts


Another simple but hopefully effective tag: adding rel=”nofollow” to a link is designed to keep the link from having any affect on your page's ranking in search engines. Of course, the search engine has to implement this, and Google, Yahoo, and Bing already have. It would be ideal to add this to any links in blog comments, so that they wont' affect your site, and won't get any credit for their own.

So, What are you going to do?

We've briefly covered a healthy number of microformats; but the question remains: are they worth your time? Not until you start using them! Microformats are made to make page scraping for data easier, but until they're widely used, there won't be very many tools for them. Although a lot of these may seem pointless now, hopefully they will be everywhere in a few years. When that happens, the tools to make use of them will be available. Microformats are definitely worth your time: so easy, so inexpensive, so potentially powerful.

Will you implement microformats into your sites?

I've hidden a microformat in this tutorial; can you find it?

Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.