A lot of web developers, at least over the years, seem to have fallen for Microformats. Naturally, the given question then is: do we really need Microformats?
What are Microformats?
According to the Microformats web site:
Designed for humans first and machines second, microformats are a set of simple, open data formats built upon existing and widely adopted standards.
Put in more plain English, it’s about marking up your (X)HTML with semantic and predefined class names and ids. If everyone uses the same class names for a certain type of data, we can write programs to parse it.
Let’s take three examples of the most popular Microformats:
<span class="tel"> <span class="type">home</span>: <span class="value">+1.415.555.1212</span> </span<
<div class="vcard"> <a class="fn org url" href="http://www.commerce.net/">CommerceNet</a> <div class="adr"> <span class="type">Work</span>: <div class="street-address">169 University Avenue</div> <span class="locality">Palo Alto</span>, <abbr class="region" title="California">CA</abbr> <span class="postal-code">94301</span> <div class="country-name">USA</div> </div> <div class="tel"> <span class="type">Work</span> +1-650-289-4040 </div> <div class="tel"> <span class="type">Fax</span> +1-650-289-4041 </div> <div>Email: <span class="email">email@example.com</span> </div> </div>
<div class="vevent"> <h3 class="summary">XYZ Project Review</h3> <p class="description">Project XYZ Review Meeting</p> <p> To be held on <abbr class="dtstart" title="1998-03-12T08:30:00-05:00"> 12 March 1998 from 8:30am EST </abbr> until <abbr class="dtend" title="1998-03-12T09:30:00-05:00"> 9:30am EST </abbr> </p> <p> Location: <span class="location">1CP Conference Room 4350</span> </p> <small> Booked by: <span class="uid">guid-1.host1.com</span> on <abbr class="dtstamp" title="19980309T231000Z"> 9 Mar 1998 6:00pm </abbr> </small> </div>
Does this really go all the way?
I’m a big fan of semantic mark-up, and having structure and value in the code. However, looking at various Microformats implementations, I think it’s valid in some cases, but just bulk code with non-semantic names in others. Well, why not add semantic value if you can, you might ask; especially since XHTML 2.0 doesn’t seem to be happening (at least not in a long time), and the semantic value added with HTML 5 is very sparse.
My reasoning is that, for one, almost every time you use it, you will get a lot of bulk code. Secondly, having your HTML code riddled with
span elements since there are a number of times when you can’t find anything more suiting, it doesn’t really enrich the code in my eyes. And, take a look at these class names examples:
- fn apparently stands for full name. Why not first name? Or function as many would interpret it? In Swedish, it’s also a short version of writing damn or fan (which means the devil). Not how I’d like to mark up a contact.
- Stands for organization, but could just as well mean organic or anything else.
- I think it’s highly unwise to use the exact name as a class name, that is an attribute of another element.
- I said, I think it’s highly unwise to use the exact name as a class name, that is an attribute of another element.
- Yeah, vEvent to match vCard. Handy, but it does feel a bit forced, don’t you think?
- Stands for date start. How about adding two letters, to get a real semantic value?
- Stands for date end. Again, how about adding two letters, to get a real semantic value?
- Stands for date stamp. Two more letters? Semantics, anyone? No?
One of the ironies here is that some Microformats supporters like to point to the W3C document Use class with semantics in mind. Would you say above classes really match that statement? And, overall, it would be so easy to actually make those class names a lot more semantic, but that ship has practically sailed since it’s been around for some years and everything is adapted to it.
And another thing which really annoys me in the above example code is using the
title attribute of the
abbr elements to display the date value for machines. For example:
<p> To be held on <abbr class="dtstart" title="1998-03-12T08:30:00-05:00"> 12 March 1998 from 8:30am EST </abbr> </p>
Do you use it?
What this all boils down to is two questions?
- Do you use Microformats?
- What do you think of Microformats?