While the hyperlink may be one of the cornerstones of the World Wide Web, it lacks in a few areas, one of them being that it doesn’t make clear what the relationship is between the source (the page that displays the link) and the destination page. This is especially pertinent in the case of web pages that are linked between friends or known associates, rather than the functional links that might occur between, perhaps, a library and a local council web site.

XFN is the solution to this quandary; its birth signalled the birth of Microformats as a whole. The XFN schema was the brainchild of well-known web luminaries Tantek Çelik, Eric Meyer, and Matt Mullenweg who, upon coming up with the idea as a way to identify social connections between web pages, realized that the concept of defining small, bite-size standards to fill perceived gaps in the HTML standards might have potential. Microformats was the response they created to meet this need.

Put simply, XFN—which stands for XHTML Friends Network (don’t be fooled—it can be used with HTML too)—uses the a element’s rel attribute to identify the relationship of a link. It contains one or more space-separated values from the list below (which, depending on the category, may or may not be mutually exclusive):

  • friendship (one value from the list only): "contact", "acquaintance", "friend"
  • physical: "met"
  • professional: "co-worker", "colleague"
  • geographical (one value from the list only): "co-resident", "neighbour"
  • family (one value from the list only): "child", "parent", "sibling", "spouse", "kin"
  • romantic: "crush", "date", "muse", "sweetheart"
  • identity: "me"

A typical use of XFN might be for a blogroll (a list of links to friends’ web sites that you feature on your blog, though it could equally link to the web sites of people you don’t class as friends, but whose work you admire or appreciate). If you wanted to link to your wife’s web site, you might use something like this:

I was talking to <a href="http://thewifeslovelywebsite.com"
rel="met spouse">the other half</a> about the idea …

Arguably, the biggest problem here is referring to her as “the other half.” But the XFN attributes are great!


Here’s an XFN-formatted link showing that the destination web site belongs to someone who the linker classes as a friend, and who that person has met:

<p>I finally got to speak to
<a href="http://www.djformat.com/" rel="friend met">Matt</a>
about the gig he did in Southampton.</p>

What's the Benefit of Using XFN?

While there may have been a massive emergence of social software in recent times, much of the data is not portable, or at least was not at the time of writing. Hence it becomes very frustrating to have to enter data for each site over and over again. While XFN is not really in the same league as many of these web sites, one could argue that by implementing it when you link to others, you are defining a social network of a kind. This meta information that you are adding can be used by aggregator services to pull out and identify relationships beyond simply knowing that “this is a link.” You could also use the XFN value in the rel attribute for the purposes of styling links in CSS differently depending on their types (although this approach requires the browser to support CSS attribute selectors). So, for the sake of argument, you could create a rule in your style sheet so that any link that has a rel attribute of "spouse" pulls in for the link a background image of a ball and chain. Whether that would be a wise implementation is another question entirely!

For more examples of XFN in use, refer to the implementations page on the Microformats site.

User-contributed notes

Related Products