This comment to my recent Think Vitamin article comes up quite frequently regarding the use of the class attribute in some microformats. I should add this as an FAQ at Microformats.org. Actually, I just did. Don’t you love wikis?
Wait a minute! I thought one of the main goals of CSS was to separate data from presentation. Isn’t this sneaking data back into presentation?
This is a quite commonly expressed objection to the way microformats uses class, but it’s based on a misunderstanding of the way the class attribute in HTML was designed. Yes, class is very commonly, and appropriately used by web designers in conjunction with CSS to style pages, and in truth, it is often overused for that, but despite this, class, according to the HTML specification “has several roles in HTML”, including “for general purpose processing by user agents”.
Microformats utilize this second aspect of the class (and id) attribute, and do so legitimately. It is not an abuse of the class or id attribute to use it to add semantic context to a document. Nor is the use of class in and of itself presentational - in fact, it is an important mechanism for separating presentation from structured content.
For some more on using class semantically, here are some articles
- Competent Classing, by Eric Meyer
- A touch of class by Tantek Çelik
- Use class with semantics in mind, W3C
- More about the class attribute, Tantek Çelik


{ 1 } Comments
Hi,
i think, regarding class names *mainly* to enhance semantics and, if possible, not at all for achieving a whatsoever look, is the best way to get well-structured and easy to maintain html pages. For css it does not matter if you call a div container “navigation” or “left200pxfloat”, but for the html and the data structuring this makes a huge difference. Thanks for this article!
{ 1 } Trackback
[…] Ein weiterer Beitrag ist “Use or abuse of class”. Hier geht er auf die Frage ein, ob Mikroformate nicht etwa das Attribut class (und id) entgegen der Zielsetzung, Inhalt von der Präsentation zu trennen, missbrauchen. Zusätzlich verweist er auf einige Links zur semantischen Benutzung von class. […]
Post a Comment