microformats2-faq

From Microformats Wiki
Revision as of 10:08, 23 October 2012 by Tantek (talk | contribs) (s/fn/name)
Jump to navigation Jump to search

<entry-title>microformat 2 FAQ</entry-title>

Frequently asked questions about microformats-2.

why are microformats 2 properties prefixed

Q: Why do microformats 2 property class names have prefixes like 'p-', 'u-', 'dt-', 'e-' ?

A: For the benefit of both web authors and developers of parsers/consumers. By using class names with a small handful of short easily recognizable prefixes, it's easier to see which class names belong to microformats, and which may serve other purposes on the page. This helps web designers better recognize and maintain support for microformats across site redesigns for example. In particular:

  • The 'p-' prefix is for typical string properties and parsing thereof.
  • 'u-' is for URL-like properties whose values often come from another attribute such as the <a> 'href' or <img> 'src'.
  • 'dt-' is for date and time related properties that have a particular format themselves, and ideally should make good use of the HTML5 <time> element, though for backward compatibility they work on any element.
  • Finally, 'e-' is for properties whose value is the entirety of the text and HTML inside an element, as represented by the element's DOM. The 'e-entry-content' property from hAtom for example permits marking up and parsing/extracting an entire post from an HTML blog post page to an Atom feed entry with full markup/DOM fidelity of the original post.

Since prefixes determine specific parsing rules, parser developers are able to write simple and efficient generic microformats 2.0 parsers without needing to know any specific vocabularies, either currently or in the future. These are both advantages of microformats 2.0 over original microformats. For more details, including why and how microformats 2.0 class name prefixes were developed, see: microformats-2-prefixes.

does microformats 2 combine vocabularies and syntax

Q: Does microformats 2 combine vocabularies and syntax?

A: No. From a parsing perspective, microformats 2 syntax is independent of any particular vocabulary. There are some microformats-2-brainstorming proposals that take advantage of semantic HTML to imply certain common properties (name, url, photo) but that's an extremely limited set that's been determined from common markup patterns.

does microformats 2 split vocabularies and syntax

Q: Does microformats 2 split vocabularies and syntax?

A: Yes, microformats 2 specifies a syntax for parsing microformats which is independent of any specific vocabulary. So in that sense it can be said that microformats 2 splits vocabularies and syntax.

are microformats 2 vocabularies available to other languages

Q: Are microformats 2 vocabularies available to other languages?

A: Existing microformats vocabularies have profiles which are already available to other languages. Each term is defined by a URL ending in a hash and the term. This is due to the design of XMDP which deliberately produces such URLs which are compatible with microdata, RDF, and any other LinkedData system. microformats 2 vocabularies will use the same profile format and thus also be available to other languages.

how do you convert a microformats 2 example to RDFa syntax

Q: How do you convert a microformats 2 example to RDFa 1.1 syntax?

A: In short you have to use the 'typeof' attribute for the microformats 2 root class name, and use the 'property' attribute for microformats 2 properties.

E.g. this from the microformats 2 page:

<h1 class="h-card">
 <span class="p-name">
  <span class="p-given-name">Chris</span>
  <abbr class="p-additional-name">R.</abbr>
  <span class="p-family-name">Messina</span>
 </span>
</h1>

Here is the same markup with RDFa 1.1 syntax, using an implied or explicit RDFa Profile from somewhere else (undefined):

<h1 typeof="h-card">
 <span property="p-name">
  <span property="p-given-name">Chris</span>
  <abbr property="p-additional-name">R.</abbr>
  <span property="p-family-name">Messina</span>
 </span>
</h1>

The similarity of these two markup examples implies that it may be possible to extend RDFa 1.1 compliant parsers to become compliant microformats 2 parsers.

see also