Microformats Would Benefit From a Namespace
Published on September 13, 2007 (⻠June 19, 2024), filed under Development (RSS feed for all categories).
This and many other posts are also available as a pretty, well-behaved ebook: On Web Development.
Microformats (âsimple, open data formatsâ) become more and more popular, accelerated by the questionable success of the nofollow
microformat. However, those of them that mandate class names cause problems that could be avoided by using a âpseudo-namespace.â
The idea behind namespaces is not new, and they already mean an aid in large projects as part of a defensive development strategy. They basically mean to add a prefix to ID and class names in order to create more efficient style sheets, preserve meaning, and ensure flexibility.
For microformats, not using something like namespaces means problems that will turn critical in the long run:
Right Now, Microformats Limit âRegularâ Web Development
The hCard microformat alone blocks more than 20 class names, use of hCalendar blocks 3, at least, and other microformats also require class names that might be legitimate names for other uses. This means a limitation: Once an author settles for a microformat, use and, above all, formatting of certain classes can become a problem.
Example: Use of a photo
class. It can usually be used at will, but when using hCard, hCard âblocksâ this class since the styling of photo
is now restrictedâit might affect the hCard presentation (this âmightâ is problematic enough). It is not an option to, say, format .photo { padding: 1em; }
, only to add .vcard .photo { padding: 0; }
. Any other enforced modification of selectors means a limitation, too, as in .section-that-contains-no-microformat .photo
. This is inelegant, inefficient, and shouldnât be acceptable.
A general or microformat-specific prefix would mitigate this: mf-photo
, for example, leaves authors all room to use names they wish; at least it reduces the likelihood that there are conflicts. It means a âwin/winâânot only will it become simpler to add microformats to projects, but could the microformats community also go on creating more formats.
Right Now, Microformats Cause Unnecessary Cognitive Load
As the former point shows, some microformats affect authoring by adding an unnecessary cognitive burden: âWhat class names cannot be used safely anymore, because theyâre occupied by microformats?â
This is a question nobody should be forced to ask. Microformats may be cool, but itâs not their job to constrain web development and to make work harder. This is a strict point of view, but theoretically, development of microformats could result in blocking every name available; meaning that one day, thereâs need to create class name whitelists for web authors (this is probably an exaggeration).
But hopefully, the point is clear: The uncontrolled spreading of microformat class names isnât trivial and has a clear impact on everyday work, as soon as people want to use microformats but also like to stay independent. A simple thing like a prefix might help, so that anyone can use microformats and at the same time be unconstrained when it comes to other code.
Right Now, Microformats Introduce Unnecessary Layout Risks
For the reasons already mentioned, the larger the project and the more decorators, designers, and developers involved, the greater the likelihood that there are unforeseen display problems maintaining and expanding the respective project. Microformats currently require developers to be aware of the constraints imposed by microformats. This is, again, avoidable.
⧠The argument had to ignore the history of certain microformats, like hCardâs intentional congruence with vCard. Itâs biased towards namespaces, as these must not mean the only solution. For some, the mentioned problems might appear abstract and distant; in that case I hope that thereâs agreement that itâs useful to look for solutions that avoid problems by design.
I ask the microformats community to reconsider current naming practices at least not to amplify the mentioned problems. In the long run, microformats should not stand in their own way.
Curiously, this is one of the most challenging articles Iâve ever written. Even now, after about 20 reviews and revisions, Iâm still not happy. On the other hand, Iâm passionate about the subject. Iâm looking forward to your thoughts.
Update (September 14, 2007)
Both comments and discussion brought up two other aspects:
-
I understand that microformats sympathizers do not feel good about having a set of class names like, as with hCard,
uf-vcard
,uf-fn
,uf-org
,uf-adr
,uf-region
, and so on. I canât say that I love it, either, but this is what would help. -
Thereâs a consequence thatâs been left out before. I may cite my mail to Ryan from Technorati:
Thereâs a reverse side, though: Several people might indeed want to style elements with the same class names the same way (assuming semantical agreement, this makes total sense). But, it still seems to mean better, more âunobtrusiveâ [microformat] design to require CSS modifications then.
Update (September 17, 2007)
Another discussion snippet just sent for clarification:
-
Regarding HTML, current web dev practice focuses mostly on styling, while microformats focus more on semantics (great). This difference in focus should underscore why thereâs an increasing probability of conflicts, especially when adding microformats to large projects.
-
Predefining class names isnât trivial. vCard, for example, uses names that few authors would typically choose, and thus itâs at least questionable whether the microformats community can assume something like âconsensus on semantics.â
-
I venture that namespaces do make it easier to create new microformats. With namespaces, thereâs a very low chance that there are ever any conflicts even when the project in question uses millions of pages, thousands of IDs and classes, and hundreds of web developers. People might actually be more eager to use microformats.
About Me
Iâm Jens (long: Jens Oliver Meiert), and Iâm a frontend engineering leader and tech author/publisher. Iâve worked as a technical lead for companies like Google and as an engineering manager for companies like Miro, Iâm a contributor to several web standards, and I write and review books for OâReilly and Frontend Dogma.
I love trying things, not only in web development (and engineering management), but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (Please be critical, interpret charitably, and give feedback.)
Comments (Closed)
-
On September 13, 2007, 22:22 CEST, Chris Baker said:
Interesting. This has always been my main concern with Microformats. It will be interesting to see how the community reacts to this.
I wonder about even going as far as creating a pseudo-namespace metatag declaration in the header for parsing by automated tools.
-
On September 13, 2007, 22:24 CEST, AndrĂ© LuĂs said:
I believe everyone can understand what you mean, even with all the revisions. đ âuf-â seems like a good candidate for a microformats pseudo-namespace, btw.
I think weâre too far into the game to start re-writing every set of uf properties, though.
This is something that could be taken into consideration on future formats, but I think rewriting the existing ones is more than risky, itâs dangerous.
+1 for importance. This should be made a guideline to follow in the future. Letâs see what the good folks of uf-discuss have to say about this. đ
-
On September 14, 2007, 0:20 CEST, Scott Reynen said:
The first thing you need to realize is that microformats are already widely published, and any changes that require updating all that publishing face an uphill battle. Beyond that, it seems your three points all boil down to microformats monopolizing class names. But they only do so within the context of relatively obscure root classes.
It is not an option to, say, format .photo { padding: 1em; }, only to add .vcard .photo { padding: 0; }
Why not? This works fine in my experience. Is it just too much work, or did this actually fail for you? I donât see a significant difference between .vcard .photo and .vcard-photo.
-
On September 14, 2007, 0:27 CEST, Jeremy Keith said:
Microformats already have de-facto namespacing; the class of the root element of the microformat. The 20 classes from hcard that you mention can be used with impunity anywhere in your document. They are only parsed as hcard components when they are contained by an element with class=âvcardâ. So if youâre worried about styling images with a class of âphotoâ within an hcard differently than those outside, just use specificity. That is far, far simpler than adding even more classes to every class name used by a microformat.
-
On September 14, 2007, 1:14 CEST, Jens Oliver Meiert said:
The first thing you need to realize is that microformats are already widely published
Yes, thatâs why Iâd welcome consideration for namespaces in upcoming microformats.
Why not? This works fine in my experience. Is it too much work, or did this actually fail for you? I donât see a significant difference between .vcard .photo and .vcard-photo.
Well, I refer to the additional efforts. If there was
mf-photo
oruf-photo
, one wouldnât even need to think about, let alone change anything whenphoto
was used.Microformats already have de-facto namespacing; the class of the root element of the microformat.
Probably for microformat parsing, but not for CSS development. The microformat root means certain context, but it doesnât give the freedom that the suggested namespaces offer.
The 20 classes from hcard that you mention can be used with impunity anywhere in your document.
Thatâs what I wanted to disprove with the
photo
class example. If any of these classes is used in another contextâand current practice makes that more and more likelyâwhere it is treated (presented) differently, problems arise, and be it âjustâ an additional rule to overwrite styling for that element within the microformat context.That is far, far simpler than adding even more classes to every class name used by a microformat.
I didnât propose to add more class namesâinstead, they should be prefixed.
-
On September 14, 2007, 13:59 CEST, AndrĂ© LuĂs said:
I donât think you should disregard this topic just because it hasnât bitten you in the rear, yet.
As far as my experience goes, Iâve never had any types of collision. And if I did, I think I overlooked it since specificity is your friend.
And I also like the position on semantic relevance. If itâs a photo, itâs a photo everywhere. If not, you just need to write your css carefully and thatâs not just about microformats. If you write careless css code, youâll bump into more problems than collision with uf. đ
Still, keep this in the back of your head when spec-ing new formats⊠that shouldnât hurt, should it?
-
On September 14, 2007, 17:10 CEST, Jens Oliver Meiert said:
Well, just because we who discuss here never had these problems doesnât mean that they donât exist. Problably symptomatic of theory đ
(Some comments removed.)
-
On April 23, 2008, 21:24 CEST, Jordan Clark said:
PS: A handy resource that will help people avoid the class-name clash is the microformats document on existing classes.
-
On April 23, 2008, 21:24 CEST, Jordan Clark said:
Bang on. Donât get me wrong, I think microformats are great, but one thing that concerned me was the âblockingâ of classes, as you put it.
I had already used class names such as email, logo, and url etc. in different contexts, and I had no choice but to rename them. Seeing as my personal website is quite small*, it was not a big problem, but it would be for a lot of medium- to large-scale websites.
-
On February 16, 2009, 12:47 CET, Andy Mabbett said:
Twitterâs hCards on user profiles are broken, because they use class=âlabelâ, within their hCard mark-up, but for marking up the text labels of fields, not for formatted addresses (e.g [span class=âlabelâ]Name[/span]).
Improvements to the hCalendar microformats on Wikimedia Commons had to be rolled back, because class=âdescriptionâ was already in use for an unrelated purpose.
Read More
Maybe of interest to you, too:
- Next: Cost of Solution vs. Cost of Problem
- Previous: 7 Additional Ways to Focus on Users
- More under Development
- More from 2007
- Most popular posts
Looking for a way to comment? Comments have been disabled, unfortunately.
Get a good look at web development? Try WebGlossary.infoâand The Web Development Glossary 3K. With explanations and definitions for thousands of terms of web development, web design, and related fields, building on Wikipedia as well as MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.