All in the <head>

– Ponderings & code by Drew McLellan –

– Live from The Internets since 2003 –

About

Adding hCard to Vitamin

26 April 2006

Last week the good folk over at Carson Systems launched Vitamin, a new and thoroughly modern magazine-style training resource for web professionals. I think the site’s gorgeous, and the content so far appears to demonstrate that there’s more to Vitamin than just a pretty face.

Something struck me about the site as soon as I saw all the list of advisors. It’s the perfect candidate for exuberant use of the hCard microformat, so I dropped Ryan Carson a line and made the suggestion. Ryan’s interest was piqued, and he took me up on the offer to work through some examples.

Retrofitting

Retrospectively working a microformat into someone else’s page is quite a enlightening experience, as it turns out. The main thing I was reminded of was that clean, well structured markup (which thankfully is what I was working with) makes any future amendment or maintenance job tremendously more efficient. I think in nearly every instance, the content I was needing to attach a new class name to already had a strong, logical container that I could reuse. Good markup pays, people.

The second big lesson from a microformats point of view is that it helps to be familiar with commonly used class names from the start. I came across a number of well-chosen class names like company already being used for CSS, which I then had to supplement with hCard’s org class name. This felt a little redundant. In my own work, I think it would be useful to try and use sanctioned class names wherever possible, even if I have no intention of applying a microformat at the time. Should my needs change later, this would help me keep the markup tight without having to go back and make big changes to my stylesheets.

Joining disparate data

One practical issue you sometimes come across, particularly with hCard although it applies to other formats too, is that the information you need to wrap up together is spread around on different parts of the page. This was the case for the general contact information on the About page – I had all the contact details, but the word ‘Vitamin’ which I needed for the name of the card, wasn’t anywhere close by.

A technical solution for this is provided in the form of the include pattern, which uses an OBJECT element to reference one partial code block from another. I can see that this is a workable idea, but to me it feels like too much of a hack. Or if not a hack, it just feels like an inelegant solution. Certainly in this case it would have been a rather unwieldy sledgehammer for a distinctly puny nut. Instead, I opted to slip the name into the content and hide it with CSS. So “Contact Details” became “Vitamin Contact Details” with the first word wrapped in a span and given the old display:none; heave-ho.

All in all it was a very painless exercise, which is one of the objectives of microformats, after all. You can see the hCards at play on the Home page, the About page and on the Advisory board page too. Obviously it’s quite a big site, but this is a strong start on some key pages.

- Drew McLellan

Comments

  1. § Colin D. Devroe:

    Don’t forget to add them to comments.

  2. § Stuart Homfray:

    Nice one, Drew – I wish I’d have thought of that during the development stage of the site! :)

Textile Help

Photographs

Work With Me

edgeofmyseat.com logo

At edgeofmyseat.com we build custom content management systems, ecommerce solutions and develop web apps.

Recent Links

Affiliation

  • Web Standards Project
  • Britpack
  • 24 ways

About Drew McLellan

Photo of Drew McLellan

Drew McLellan (@drewm) has been hacking on the web since around 1996 following an unfortunate incident with a margarine tub. Since then he’s spread himself between both front- and back-end development projects, and now is Director and Senior Web Developer at edgeofmyseat.com in Maidenhead, UK (GEO: 51.5217, -0.7177). Prior to this, Drew was a Web Developer for Yahoo!, and before that primarily worked as a technical lead within design and branding agencies for clients such as Nissan, Goodyear Dunlop, Siemens/Bosch, Cadburys, ICI Dulux and Virgin.net. Somewhere along the way, Drew managed to get himself embroiled with Dreamweaver and was made an early Macromedia Evangelist for that product. This lead to book deals, public appearances, fame, glory, and his eventual downfall.

Picking himself up again, Drew is now a strong advocate for best practises, and stood as Group Lead for The Web Standards Project 2006-08. He has had articles published by A List Apart, Adobe, and O’Reilly Media’s XML.com, mostly due to mistaken identity. Drew is a proponent of the lower-case semantic web, and is currently expending energies in the direction of the microformats movement, with particular interests in making parsers an off-the-shelf commodity and developing simple UI conventions. He writes here at all in the head and, with a little help from his friends, at 24 ways.