SpyreStudios

Web Design and Development Magazine

  • Design
  • Showcase
  • Inspirational
  • Tutorials
  • CSS
  • Resources
  • Tools
  • UX
  • More
    • Mobile
    • Usability
    • HTML5
    • Business
    • Freebies
    • Giveaway
    • About SpyreStudios
    • Advertise On SpyreStudios
    • Get In Touch With Us

Real World Embedded Metadata – RDFa, Microformats And Microdata Practical Examples

July 7, 2010 by Marco Lisci 12 Comments

Have you ever seen those small grey descriptions in Google search results below the title? If you’re curious on how to get them, then the answer is embedded metadata.

With the words embedded metadata we refer to a way to add invisible information in an HTML/XHTML document. These informations will be machine readable, by Google or Yahoo for example, but will not be seen in the browser. Basically we’re going to add some properties to our HTML elements that will say to Google: “Hey, this h1 title is my name, and this h2 title is my work title, I’m a web developer“. As a result Google will show in the search results, under our page title, a little line with our name and our work title.

Google embedded metadata Results

There are three main embedded metadata specifications that are struggling to become a standard, and probably none of them will be 100% standard like it’s happening with HTML5, so it’s better to have a basic understanding of how all of them work. The projects are:

  • RDFa: a specification strictly connected with XHTML, supported with the XHTML1.1 doctype
  • Microformats: the most diffused specification till the arrive of HTML5
  • Microdata: the HTML5 specific set of instructions.

The history of the formats shows how RDFa started the topic, basing everything on the Resource Description Framework; it’s complex but well supported.

Then arrived Microformats, with his friendly structure and became very popular. With HTML5, the group decided to create his own version of interconnected information organization. Let’s avoid asking if we really needed another specification for this standard, and let’s start seeing some example on how enrich our HTML with a machine readable representation of data.

We’re going to see how the three different standards can be used to represent our name and our work title, in a typical about me page. These informations could be added to google search results and every future applications that will use embedded metadata.

RDFa

Let’s start with an RDFa example:

[html]
<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Person">
<p>Name: <span property="v:name">Marco Lisci</span></p>
<p>Title: <span property="v:title">Web Developer</span></p>
</div>
[/html]

First of all RDFa needs a proper name space when working with it, to avoid conflicts in the XML tree. So we’re going to add the xml schema, with xmlns:v=”http://rdf.data-vocabulary.org/”, the official Google RDF schema. Then we have to declare the type of what our informations are going to represent, in this case a Person adding typeof=”v:Person”.

If you look at the documentation, there are a lot of other types that can be used, according to our needs. Then, using the v root, we’re going to add the properties to our span elements. Using v:name, we’re telling to the system that will read our page that what’s inside the span is the name of the person we want to represent. And the v:title will be read as the title of the current person. As you can see, you’re not breaking the XHTML, it’s about adding some little properties that can be really useful. You can find the entire specification on the W3 website.

Microformats

Microformats are far simpler that RDFa. The reason is clear, there’s no need to specify an xml schema and use properties. It’s all about using special names in classes. So our previous example will be:

[html]
<div class="vcard">
<p>Name: <span class="fn">Marco Lisci</span></p>
<p>Title: <span class="title">Web Developer</span></p>
</div>
[/html]

Yes, it’s really so simple. Just add the class vCard to the wrapper element, and add fn to the name span element (the fn is the only required class), and title to the work title span element. This is the representation of hCard microformat element. By doing this, Google and other softwares will be able to grab the info and use them.

There are a lot of other elements that you can use to enrich your hCard representation, all listed at the official hCard page. There’s also an hCard creator, a little form to create an hCard representation from your info. I think that Microformats are really great, but if you’re following the HTML5 train, you can’t miss microdata.

Microdata

Microdata are the Microformats for HTML5. and this spec has it’s own DOM API, so it could become the standard when HTML5 will be widely spread. We can already start using it since Google announced microdata support. So, let’s take a look at how it works:

[html]
<div itemscope itemtype="http://data-vocabulary.org/Person">
<p>Name: <span itemprop="name">Marco Lisci</span></p>
<p>Title: <span itemprop="title">Web Developer</span></p>
</div>
[/html]

You can see more than one similarity with RDFa. Also in this case you have to add a data vocabulary with itemtype. We used again the official Google vocabulary for microdata. The other important thing is to add itemscope to the wrapper element of all your informations. Then with itemprop we can assign to our spans the name and title values. It’s a little bit complex compared to Microformats, but could become the standard.

Useful links.

When you’ll get a little confidence with these three standards you’ll want to add more and more infos to your pages. Every one of these standards has schemas and properties for the most common informations used on the web, even nested elements, but they’ll follow the simple structure described here. The official specification page of RDFa is at the W3 website, it’s a little bit complex, but useful to understand deeply the Resource Description Framework.

There’s also the Microformats Wiki, and it’s the project with the best documentation among the three. Then there’s the microdata specification.

Remember that all of them are Google ready, so pick one and start experimenting! I personally use Microformats, but I’ll switch to HTML5 Microdata if it will show a solid foundation.

Your Turn To Talk

I hope you found this article useful. Please feel free to chime in by leaving a comment below! ;)

Filed Under: Article, Resources, Tools, Tutorial

Comments

  1. Manu Sporny says

    July 7, 2010 at 9:43 pm

    Hi Marco,

    My name is Manu Sporny – I’m currently one of the Chairs of the RDFa Working Group and have also been very heavily involved in the Microformats community over the years. There are a couple of issues with the article that I wanted to highlight, perhaps you could correct them?

    Microformats don’t refer to RDFa or Microdata – Microformats are their own thing. One could think of all of this stuff as Microformats, but it really confuses people when you say that RDFa is both a Microformat and RDFa. Strictly speaking, Microformats are not RDFa. Microformats are not Microdata. Each has its own language syntax.

    RDFa is not only defined for XHTML, but it is also being defined for HTML5 and HTML4.01. RDFa will soon be available for all major HTML languages used on the Web today:

    http://www.w3.org/TR/rdfa-in-html/

    Your examples seem to be a bit off – the RDFa example should be:

    <div xmlns:v=”http://rdf.data-vocabulary.org/#” typeof=”v:Person”>
    <p>Name: <span property=”v:name”>Marco Lisci</span></p>
    <p>Title: <span property=”v:title”>Web Developer</span></p>

    Your Microformats example should be:

    <div class=”vcard”>
    <p>Name: <span class=”fn”>Marco Lisci</span></p>
    <p>Title: <span class=”title”>Web Developer</span></p>
    </div>

    Your Microdata example should be:

    <div itemscope itemtype=”http://data-vocabulary.org/Person”>
    <p>Name: <span itemprop=”name”>Marco Lisci</span></p>
    <p>Title: <span itemprop=”title”>Web Developer</span></p>
    </div>

    Other than those minor issues, good story. :)

  2. Jon Phillips says

    July 8, 2010 at 2:02 am

    @Manu: Thank you so much for your comment, very helpful ;)
    We updated the post to reflect your comment and fixed a little problem with our code highlighter plugin. Thanks!

  3. Manu Sporny says

    July 8, 2010 at 3:47 pm

    Also note that with the new RDFa 1.1 stuff, you can achieve markup that is just as simple as Microdata (via the @vocab attribute) and Microformats (via RDFa Profiles). The following example demonstrates how you can use @vocab in RDFa 1.1:

    <div vocab=”http://rdf.data-vocabulary.org/#” typeof=”Person”>
    <p>Name: <span property=”name”>Marco Lisci</span></p>
    <p>Title: <span property=”title”>Web Developer</span></p>
    </div>

  4. Joost Kiens says

    July 8, 2010 at 10:26 pm

    Interesting stuff, I have only experimented with microformats.

    Recently I rewrote my resume (http://resume.impendulo.net) with microformats: hCard, hResume (which uses hCalendar as well) and html5.

    There were a few semantic issues, like hCalendar not allowing the usage of the html5 time element. But in the end it came out pretty well.

    One thing that’s easy to miss from the microformats wiki is that, if I understand correctly, you should declare which microformat profile you use, like or in a meta tag.

    One thing that I found useful is checking your embedded metadata with Google’s rich snippet tool (http://www.google.com/webmasters/tools/richsnippets).

    Anyway, I might have a look at microdata or RDFa with html some time soon. Thanks for the article

  5. teebee says

    July 9, 2010 at 2:30 pm

    FYI: The code block under “Microdata” has an error. “itemscope” in the div block isn’t quite there!

  6. Jon Phillips says

    July 10, 2010 at 1:27 am

    @teebee: Thanks for the heads up! It’s fixed now.

  7. Sun Pietro says

    July 11, 2010 at 3:33 pm

    Hi,
    great article, but I have one question. How can you build an onsite search engine using these languages? For example to search people that are web developers?

  8. Jordan Walker says

    July 12, 2010 at 10:03 am

    Very informative post, glad to learn something new on Monday!

Leave a Reply

Your email address will not be published. Required fields are marked *

Please prove you're human *

Recent Posts

  • 31 Fresh Design Elements for Spring and Easter
  • 10 Templates for Music Concert Flyers
  • How to Build a Web Scraper Using Node.js
  • Best PHP Books, Courses and Tutorials in 2022
  • How to Get Your First Web Design Client

Archives

  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • May 2008
  • April 2008

Categories

  • Accessibility
  • Android
  • Apps
  • Art
  • Article
  • Blogging
  • Books
  • Bootstrap
  • Business
  • CSS
  • Design
  • Development
  • Ecommerce
  • Fireworks
  • Flash
  • Freebies
  • Freelance
  • General
  • Giveaway
  • Graphic Design
  • HTML5
  • Icons
  • Illustrator
  • InDesign
  • Infographics
  • Inspirational
  • Interview
  • Jobs
  • jQuery
  • Learning
  • Logos
  • Matrix
  • Minimalism
  • Mobile
  • Motion Graphics
  • Music
  • News
  • Photoshop
  • PHP
  • Promoted
  • Rails
  • Resources
  • Showcase
  • Tools
  • Tutorial
  • Twitter
  • Typography
  • Uncategorized
  • Usability
  • UX
  • Wallpapers
  • Wireframing
  • WordPress
  • Work

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

SpyreStudios © 2022