Understanding RDFa

Since microformats typically don’t try to solve specific cases for niche fields, RDFa picks up where microformats leave off by adding an open-ended mechanism for extending the semantics of markup without limitations from the host markup language itself. In other words, RDFa is a simple and, more important, language-agnostic way of giving documents the means to be self-describing. RDFa uses a set of attributes (hence the trailing “a”) that can be attached to any element whose values reference other elements in the same or other documents.

As you know, when you view a web page you’re asking your web browser to fetch a document. This document is just a text file that happens to be constructed in a special way. It’s constructed according to the syntax and grammar of a particular markup language so that all the content it contains is represented in a structured format.

It turns out that this structure has some remarkable similarities to human languages. Put simply, when we construct sentences in human languages we often use a grammatical structure that begins with a subject, followed by a verb, and that then ends with an object.

Markup languages also have rules of grammar. There are elements, each a building block or component of the larger whole. An element can have certain properties that further specify its details. These properties are often attributes, but they can also be the element’s own contents. Finally, an element has a certain position within the document relative to all the other elements, giving it a hierarchical context.

That markup languages contain rudimentary but powerful grammars in three major forms: which elements are being used, which attributes and attribute values those elements have, and the hierarchical context of elements in relation to one another. The ability to nest one element within another creates implicit relationships between different elements, but is structurally limiting. If elements are required to be nested to reference one another, neither the document itself nor the rest of the Web can be flexibly structured.

RDFa adds a fourth grammatical form by allowing one element, via an attribute and value pair, to reference any other element anywhere else on the Web by way of its unique web address or URI. Rather than referring to a document, now the reference actually refers to an object—a person, idea, place, event, book, or some other thing. The attribute used to do this is the about attribute. For instance, given a transcript of a speech we can now explicitly refer to and describe it without requiring that the two pieces of markup be structurally attached to one another.

<blockquote cite="http://example.com/myspeech" id="my-speech">
	<p>Once upon a time {...}</p>

By giving this speech an explicit id attribute and unique value, we then use this value in a different element’s about attribute:

	The speech was written by
	<a about="#my-speech" property="dc:creator"
		Bobby McFerrin

Here, we’ve described the speech as being created by Bobby McFerrin. RDFa gets its name from the fact that it borrows a concept from the W3C’s Resource Description Framework (RDF) called a triple, itself merely a way of describing two objects (two “things”) with a relationship to one another. In the prior example, the quoted speech is one object (the subject), Bobby McFerrin is the other (the predicate), and the fact that Bobby wrote the speech (that is, he is the creator) is the relationship. The only magic here is that the meaning of a “creator” has already been defined by a vocabulary we’re referring to as “dc” (short for Dublin Core).

In addition to the attributes already present in XHTML that RDFa makes use of such as rel and rev, RDFa adds the following attributes:

  1. property: Specifies a URI (or CURIE, simply a more compact URI) that references a particular term in a given vocabulary; the marked-up content is then known to be that “thing.”

  2. about: Optionally provides an explicit reference to a second object that the current element describes.

  3. content: Optionally used with the property attribute to provide an explicit, machine-readable interpretation of the content of an element. For instance, an element such as <span property="dc:date" content="2009-11-30">Nov 30, 2009</span> reads to humans as “Nov 30, 2009” but reads as 2009-11-30 to machines.

  4. datatype: Optional CURIE that specifies the data type of text specified for use with the property attribute (for example, string or integer, useful for ensuring data integrity for machine processing).

  5. typeof: Optional CURIE value that declares a new data item.

  6. resource: A URI or CURIE, which expresses the resource of a relationship.

It’s this flexibility with the RDF triple and the extensible, highly specific capabilities that RDFa brings to markup languages that distinguishes it and makes it infinitely more scalable than the microformats initiative. Some might consider these two technologies in competition, but really they are not; both are simply differing approaches to solving the same challenge of having a more semantic and understandable markup framework on the Web. Some crossover exists, but both microformats and RDFa can coexist within the same markup.

Related Resources

Wikipedia – RDFa

A List Apart – Introduction to RDFa

A List Apart – Introduction to RDFa II

There have been 3 comments | Subscribe to Comments | Jump to Form »

Philip Jägenstedt

Your examples don’t define the dc prefix, without it dc:creator means nothing. In some more recent version of RDFa you could always write http://purl.org/dc/elements/1.1/creator instead.


Ted Goas

Thanks for this article, it really clears up a lot for an microformat / RDFa novice. Do you work with RDFa much? If so, what kind of projects?


Mert TOL

@ Ted Goas :

Thanks for this article, it really clears up a lot for an microformat / RDFa novice. Do you work with RDFa much? If so, what kind of projects?

Thanks Ted. Yes, I’m and my team working with RDFa and microformats. But, we’ll work much more… These projects are—we’re working—generally web sites for the goverments and some mobile applications.

BUT, I can say this, microformats and/or RDFa will be much more important in 3-5 years and people who wants to be success in our industry will use them in their all projects.

I’ll publish more about microformats. Thank you for reading.


Post Comment on This Article

Your e-mail address won't be published. If you simply add some value to the original post and stay on the topic, your comment will be approved.

You can use Textile parameters on your comments. For example: _italic_ *bold* bq. quated text "link text":URL — Get your own picture next to your comment with a Gravatar account.