Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > CSS

Microformats Made Simple: XFN

  • Print
  • + Share This
Emily P. Lewis focuses on using the rel attribute for links in order to define social relationships, starting with an explanation of XFN.
This chapter is from the book

This chapter is from the book

In the last chapter, we examined how to define links using rel-based microformats and VoteLinks, which uses the rev attribute. Now we will focus on using the rel attribute for links in order to define social relationships.

What Is XFN?

XFN (XHTML Friends Network) is another elemental microformat—it uses just one attribute-value pair—that defines link relationships. But unlike the rel-based microformats, which describe relationships of href destinations to pages, XFN describes social relationships among people.

Developed by the Global Multimedia Protocols Group (GMPG), XFN evolved in response to the blogroll trend, where content authors publish links to other sites they recommend. Often these blogrolls are links to personal sites and blogs (hence the name) that are representative of the people behind them. In effect, these URLs are part of people's online identities.

XFN was created in order to represent these online identities through links, using the rel attribute and a standard set of keywords (values) that describe the relationships you, as the content author, have with the people whose sites you link to. Such relationships include whether you have physically met that person, if that person is a friend or colleague, even if that person is a family member or significant other.

Benefits of the social web

As much as I detest the term Web 2.0 (I think I just threw up in my mouth a little), it has come to represent, in part, the emergence of online social media. This includes everything from user-generated content to popular social networks like Facebook and Twitter.

XFN, too, is a part of this social web. Because it is used to describe human relationships, it supports the creation and extension of social networks. Web tools can crawl the web, searching for XFN links, and discover the social relationships among people, such as the following:

  • Dick and Jane have met and they are friends
  • Brad and Angelina are spouses
  • A Blog Not Limited and @emilylewis are the same person

Let's consider the Google Social Graph API (Application Programming Interface), which drives Google's My Connections service. With My Connections, you enter a few of your own URLs (such as that for your blog, your portfolio, and your Twitter profile page), and it uses the Social Graph API to gather links from other people with whom you've indicated a social relationship (via XFN). It also returns information about the people who have indicated, via XFN, relationships with you, including reciprocal relationships (Figure 4.1).

Figure 4.1

Figure 4.1 Google's My Connections displays my XFN social connections gathered from my blog, Twitter profile, and design portfolio.

Even better, you can use this Social Graph API to create your own social network without having to code your own application, access other APIs, or scrape sites for data. Google's Social Graph API has already indexed the sites and relationships.

And XFN is already widely used. The majority of social networking sites use XFN to describe the relationships between friends and followers using the XFN contact or friend values (assigned to links as rel="contact" and rel="friend", respectively).

Benefits of identity consolidation

Nowadays, particularly with the emergence of social networks, people exist on many different and disparate sites. You may have a blog, a Twitter profile, a Facebook page, and more. With all of these distributed sites, a user may want a way to indicate that each site represents the same person. This is known as identity consolidation, and XFN supports it.

One of the values for XFN is me (assigned to links as rel="me"). By assigning this value to the links to all of your online "identities," you are indicating that each site represents you, effectively consolidating your identity without having to centrally maintain that information.

The key to identity consolidation with rel="me" is that each site in your online identity must have this XFN value applied. The logic is where any site claims another site, the identity between the two is consolidated.

This isn't too difficult. On your own sites, you control the content and can add rel="me" where relevant. And already, many sites and services apply rel="me" to links to their users' profile pages to support identity consolidation, including Flickr, Twitter, LinkedIn, Plaxo, and ClaimID. As such, web applications can gather all of your rel="me" links to create a single profile about you.

One social service that leverages the full power of identity consolidation via XFN is Huffduffer, the audio podcasting service. It utilizes Google's Social Graph API to gather reciprocal rel="me" links from a single URL (namely, your own blog or site) in order to generate a list of "elsewhere" links (such as Twitter and Flickr) on users' profiles.

So, when you create an account at Huffduffer, you enter a URL for one of your websites, and the Social Graph API then returns a list of all other sites that belong to you, based on the presence of the XFN rel="me".

The beauty of this is that instead of editing your profile manually to include links for yourself, Huffduffer does it for you automatically, saving time and ensuring you don't have to maintain that data within the application (Figure 4.2).

Figure 4.2

Figure 4.2 My Huffduffer profile's Elsewhere links gathered via the Social Graph API

Everything has challenges

Of course, despite these powerful benefits, XFN faces some challenges:

  • There are 18 XFN values; however, the two most commonly used are friend and contact, making some folks question the semantic value of the other 16 values.
  • Some people believe there isn't enough semantic distinction between friend and contact.
  • Others suggest more values are needed to indicate narrower professional relationships beyond co-worker and colleague, such as "manager" or "subordinate."
  • There isn't a way to indicate how a relationship may change over time, such as an "ex-friend."

Regarding the first point, I truly believe that as more people adopt XFN, the use of those remaining 16 values will increase and, with it, more tools will parse and extract information for those types of relationships. Kind of a "build it and they will come" perspective.

For the other concerns, I believe people are missing the point about microformats in general: they are intended to be simple and address the majority of use-cases, not all.

Adding more values to XFN, in my opinion, would convolute the microformat and go against simplicity. In the case of professional relationships, managers are co-workers, just as subordinates are; co-worker is a global value that encompasses both managers and subordinates. I don't see the need to get any more specific. Plus, XFN doesn't prohibit you from assigning to your rel attribute a value of "manager," which you can then use to customize your own web application to extract that particular data.

Finally, in the case of changed relationships, I believe that because XFN is assigned to links at a given point in time, the indicated relationship is relevant at the time the link was created. If the relationship changes over time, the XFN values assigned to links can change, thus suggesting that changed relationship.

Now that we've covered the good and the (not really) bad, let's take a look at XFN in detail, starting with the profile.

Profile

XFN has its own profile that you should reference in the <head> of your documents:

<head profile="http://gmpg.org/xfn/11">

Syntax

The XFN syntax should be very familiar to you, since it is identical to that of the rel-based microformats. You simply add the rel attribute to links referencing other people, and apply the appropriate XFN value to indicate your relationships with those people.

For example, I often include links on my blog to my friends' sites, and I apply rel="friend" to those links:

<a href="http://twitter.com/cdharrison" rel="friend">Chris
Harrison</a>

Most of the time, though, I have more than one XFN relationship with those friends. For those cases, I can list more than one value, each separated in my markup with a space:

<a href="http://twitter.com/cdharrison" rel="friend met

colleague">Chris Harrison</a>

This compound XFN statement says:

  • Chris is a friend of mine.
  • I have met Chris.
  • Chris is my colleague.

It is worth noting that for these compound XFN statements, the order of the values is irrelevant. Just be sure to separate each with a space so that all of the values can be parsed correctly.

Understanding the values

The XFN values are listed in Table 4.1 above, but their meaning may not be entirely clear to you, so let me explain them.

Table 4.1. XFN Values

Identity

Friendship (one value)

Professional (one or both values)

Family (one value)

Romantic (any or all values)

Physical

Geographic (one value)

me

contact

colleague

kin

muse

met

neighbor

acquaintance

co-worker

spouse

crush

co-resident

friend

child

date

parent

sweetheart

sibling

Identity

The only value that falls under the identity category is me, which I've discussed in reference to identity consolidation. You apply it to links that reference URLs about you: your blog, your tumblelog, your design portfolio, or any site about you.

The one XFN value that should exist on its own is me. Yes, by some lines of thinking you have met yourself and you may even be a friend to yourself. However, these values are pretty much assumed. But hey, two thumbs up for good self-esteem and being your own friend!

Friendship

Of the three values in the friendship category, you can use only one:

  • contact is the least intimate of the friendship relationships. It is basically someone for whom you have basic contact information, such as their name and, maybe, a URL to their site.
  • acquaintance indicates someone with whom you are familiar and who is familiar with you. It's just a step above contact in terms of intimacy.
  • friend is the most intimate friendship value, but it is largely defined by personal parameters. For me, it includes people I've known for years, as well as those I know more casually but who are more than just contacts or acquaintances.

Professional

You can use either one or both of the values in the professional category:

  • colleague is a professional peer, someone with whom you share professional skills and/or interests.
  • co-worker is someone you work with for the same employer.

Family

From the five family XFN values, you can use only one:

  • kin is any relative, whether by blood, marriage, or adoption.
  • spouse is someone to whom you are married. However, it does not require legal marriage. It can also be someone to whom you feel you are married, such as gay couples who aren't legally allowed to marry or folks in common-law marriages.
  • child is anyone you parent, and applies to both biological and adoptive children.
  • parent is someone—again, either biological or adoptive—who parented you.
  • sibling is someone with whom you share a parent, either through biology, marriage, or adoption.

Romantic

You can use any one or all of the values in the romantic category:

  • muse is someone who inspires you. Now I admit that, at the outset, it seems strange to categorize this as romantic. However, the value falls under the comparative definition of romantic with rational, the thinking being that inspiration isn't rational, so it must be romantic.
  • crush is someone to whom you are attracted but doesn't return the feeling. And, in my case, someone who doesn't even know you are alive (ah, Hugh Jackman).
  • date is someone you date on a regular basis, where there isn't (yet?) a commitment to the relationship.
  • sweetheart is someone to whom you are committed and are physically and/or emotionally intimate.

Physical

The only physical value is met, and it refers to people you have actually met in person (so that would not be the guy in the chat room you just met online).

Geographic

Of the two geographic values, you can use only one:

  • neighbor is someone who lives near you, but not at the same street address. This value has broad definitions: you may consider someone who lives in your condo building a neighbor, as well as someone who lives several blocks away.
  • co-resident is someone with whom you share a street address, such as a roommate.

Another thing worth noting is that XFN doesn't require reciprocity. If you reference a person as a date and they reference you as a friend, it has no impact on the ability for machines to work with XFN. However, it may be time to have a "where are we in this relationship" conversation with that person.

  • + Share This
  • 🔖 Save To Your Account