Wherein we write down some stuff that we know.

Archive for the ‘Microformats’ Category

On Microformats

Saturday, March 25th, 2006

Scott came back from SXSW all jazzed about microformats …and really, who could blame him? It’s something so simple and easy to implement (it’s just markup) that to not embrace them is an act of stubborness.

But the first step in taking advantage of a microfomat is knowing of it’s existence. For that, we have Tails, a nifty Firefox extension that alerts you to the presence of a microformat. You do use Firefox, don’t you?

An Exercise in Microformats

Friday, March 17th, 2006

Microformats are an informal means of marking up web pages with semantically meaningful metadata to allow for greater interoperability with other applications.

About Microformats

Designed for humans first and machines second, microformats are a set of simple, open data formats built upon existing and widely adopted standards. Instead of throwing away what works today, microformats intend to solve simpler problems first by adapting to current behaviors and usage patterns (e.g. XHTML, blogging).

Ok, that’s nice, but what does it mean? Think of it with this example. If you have a page that contains contact information for a person, simply by adding a few classes to add some semantic meaning to the existing tags you could allow for a web browser or plugin to automatically recognize that there is contact information on that page and potentially prompt you to add it to your address book.

Campus Exercise

For this exercise, I’m going to take a sample page from the Campus Directory and using the hCard standard turn it into a Microformat compatible page.

Step 1: Code Clean-up

First step is to review the code that’s used to currently display the contact information.

HTML:
  1. <h2>Jungling, Scott</h2>
  2. <hr />
  3. <h3>Staff</h3>
  4. Phone: <b>898-5023</b> Campus Zip: <b>295</b><br />
  5. Building: <b>MLIB</b>, Room <b>410 </b><br />
  6. Department: <b>STCP - Student Computing</b><br />
  7. Department phone: <b>898-4357</b><br />
  8. E-mail: <i><a href=“mailto:sjungling@csuchico.edu”>sjungling@csuchico.edu</a></i><br />
  9. </ul>

The first glaring error in this code is the improper use of an unordered list tag (UL). Just reading the code aloud doesn’t make much sense. Now, I know the final product that the end user sees is understandable. However, Microformats are trying to make that code machine-readable and human-readable.

The final markup I came up with was this:

HTML:
  1. <h3>Staff</h3>
  2.     <a href=“mailto:sjungling@csuchico.edu”>Scott Jungling</a>
  3.     <div>
  4.       <strong>Department:</strong> STCP - Student Computing
  5.     </div>
  6.     <div>
  7.       Building: MLIB Room 410<br />
  8.       Campus Zip: 295
  9.     </div>
  10.     <div>
  11.       <strong>Office:</strong> 898-5023
  12.     </div>
  13.   </div>

With this code, I’ve made a few changes. I’ve moved the Staff heading out of the contact information because it wasn’t really contextually relevant when displayed after the persons name. Now viewing the code it makes a little more sense. I’ll admit that it’s a big tag happy but there are some extra bits of semantic markup which let us know what the information is. There are a few containers: vcard, org, adr, and tel. Within those containers are a few tags to hold the type and value of the data.
a few
To beautiful the way the information is displayed I added a few CSS rules to emulate the original look of the page with a few flourishes.

Finished Product

Ok, so now we’ve gone through and changed the markup to make it valid XHTML and semantically meaningful. Let’s take a look Looks about the same doesn’t it? I took out Department Phone because I imagine this is rarely used. If you’re looking for a person specifically you want to find their phone number. If you need their departments phone number you could look up the number on the department listing.

The Magic

I made a duplicate of the first version, and added the following code beneath the contact info which follows this basic format as a hyperlink:

HTML:
  1. <a href=“http://feeds.technorati.com/contacts/FULL_URL_TO_PAGE”>Add to Address Book</a>

Now when you view this version you’ll see a link that you can click that will convert the contact information on that page into a vCard file that will be downloaded to your computer and imported into either Apple’s Address Book or Microsoft Outlook.

Right now it’s using a utility on Technorati which could easily be reverse engineered to parse the hCard format. Want to make your own hCard? Try the hCard Creator It’s pretty simple.

Summary of Links