<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HTML5 Doctor &#187; Attributes</title>
	<atom:link href="http://html5doctor.com/category/attributes/feed/" rel="self" type="application/rss+xml" />
	<link>http://html5doctor.com</link>
	<description>helping you implement HTML5 today</description>
	<lastBuildDate>Wed, 16 May 2012 11:31:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>HTML5 adaptive images: end of round one</title>
		<link>http://html5doctor.com/html5-adaptive-images-end-of-round-one/</link>
		<comments>http://html5doctor.com/html5-adaptive-images-end-of-round-one/#comments</comments>
		<pubDate>Wed, 16 May 2012 10:36:45 +0000</pubDate>
		<dc:creator>Bruce Lawson</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Specification Changes]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=4645</guid>
		<description><![CDATA[<p>After The Great Vendor Prefix Hullaballoo of April 2012 comes The Great Responsive Images Brouhaha of May 2012. We look at the main competing formats for adding adaptive images to HTML - the <code>&#60;picture&#62;</code> element, and the <code>&#60;img srcset=""&#62;</code> attribute.</p>]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://dev.opera.com/articles/view/opera-mobile-emulator-experimental-webkit-prefix-support/">The Great Vendor Prefix Hullaballoo of April 2012</a> comes The Great Responsive Images Brouhaha of May 2012. </p>
<p>Adaptive images are the next unsolved mystery of Responsive Web Design. Do you send large high-res images suitable for retina dispays, which are scaled down on smaller, lower res devices and which therefore waste bandwidth? Or do you send low-res images, whch look grotty when scaled up to large screens or high-res displays? Authors have had to rely on <a href="http://css-tricks.com/which-responsive-images-solution-should-you-use/">elaborate hacks</a> to send different content images (that is <code>&lt;img&gt;</code> in HTML rather than CSS background images) to different types of devices.</p>
<p>By November 2011, I was so frustrated that no specification body was considering the problem that <a href="http://www.brucelawson.co.uk/2011/notes-on-adaptive-images-yet-again/">I proposed a strawman &lt;picture&gt; element</a> that re-used the mechanism of HTML5 &lt;video&gt; with its media queries to swap in different source files:</p>
<pre><code>
&lt;picture alt=&quot;angry pirate&quot;&gt;
   &lt;source src=hires.png media=&quot;min-width:800px&quot;&gt;
   &lt;source src=midres.png media=&quot;min-width:480px&quot;&gt;
   &lt;source src=lores.png&gt;
      &lt;!-- fallback for browsers without support --&gt;
      &lt;img src=midres.png alt=&quot;angry pirate&quot;&gt;
&lt;/picture&gt;</code>
</pre>
<p>Around the same time, others <a href="http://www.w3.org/community/respimg/2012/02/23/picture-for-existing-browsers/">independently came to the same idea</a> and were advised to set up a <a href="http://www.w3.org/community/respimg/">W3C community group</a> to discuss it which they did. However, in January, the HTML5 editor, <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-January/034490.html">Ian Hickson, had said</a></p>
<blockquote>What&#8217;s the use case for doing it for images in &lt;img&gt; elements? Typically &lt;img&gt; elements are for content images, where you don&#8217;t usually want to adapt anything.</blockquote>
<p>Those web authors in the W3C Resposive Images Community Group  soldiered on in frustration that they were they being ignored  because the problem itself wasn&#8217;t seen as a problem. Then this week, Edward O&#8217;Connor of Apple suggested another method, using a <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-May/035746.html">new <code>srcset</code> attribute</a> on the &lt;img&gt; element. This complemented a similar suggestion of his from February for <a href="http://lists.w3.org/Archives/Public/www-style/2012Feb/1103.html">img-set in CSS</a> that is already being added to WebKit:</p>
<pre><code>&lt;img src="foo-lores.jpg"
     srcset="foo-hires.jpg 2x, foo-superduperhires.jpg 6.5x"
     alt="decent alt text for foo."&gt;</code></pre>
     <p>The numbers &#8220;2&#8243; and &#8220;6.5x&#8221; tell the browser the relative resolutions; foo-hires.jpg is 2x the resolution of foo-lores.jpg.</p>
<p>Only a few days later, a variant of Apple&#8217;s suggestion was <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-May/035855.html">added to the spec</a>.</p>
<p>There are two major differences between &lt;picture&gt; and srcset. The most obvious is that srcset uses the &lt;img&gt; element, which is great because that&#8217;s the natural place for images, adaptive or not. (You can&#8217;t re-use the &lt;video&gt; + &lt;source&gt; pattern with &lt;img&gt; because it is an empty element so can&#8217;t have child elements. O&#8217;Connor&#8217;s solution uses attributes, which are fine.)</p>
<p>The other major difference is that it doesn&#8217;t use Media Queries. With Media Queries, the author is reponsible for thinking up every permuations of viewport size, orientation, dpi, colour depth, aspect ratio and the like, deciding how to cater for them (if at all), identifing the breakpoints and coding them up. This requires a lot of consideration by the author, and makes for verbose code; a page with 20 pictures, each with 5 Media Queries on 5 &lt;source&gt; elements quickly becomes a lot of code.</p><p>O&#8217;Connor wrote</p>
<blockquote>
<p>Why provide a scale factor and not a media query? Well, media queries are claims about UA state, whereas here we&#8217;re asserting something about the relationship between the image assets. Also, User Agents should be free to use whichever asset they deem best suited to their current situation, taking into account not just &#8220;media-queriable things&#8221; like device resolution but also any scaling applied to the &lt;img&gt; with CSS, its width=&#8221;" and height=&#8221;" attributes, or even things like the current page zoom level.</p>

</blockquote>
<p>I have a lot of sympathy with allowing the browser to make decisions about what it knows of the environment (network speed, latency, pixel density, orientation) to choose the best image for the job. The idea is that the author shouldn&#8217;t be expected to anticipate and cater for all those variables. What she can do is describe the things she knows about -the images, their size and pixel density- and the browser will make its choice.</p><p>That way, when we&#8217;re all living in space and looking a 3D holograms, the proximity to a black hole can be detected by the iDroid3000 device (black holes notoriously cause Web hologram negative timespace inversions) and the right image chosen; we don&#8217;t need to invent new media queries for event horizon proximity and retrospectively add it to our websites.</p>
<p>There are two problems with the srcset suggestion. The first is highly subjective, but many feel the same: as it exists in the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#attr-img-srcset">current, first draft of the spec</a>, the syntax is revolting:</p>
<pre><code>&lt;img src="face-600-200-at-1.jpeg" alt=""
srcset="face-600-200-at-1.jpeg 600w 200h 1x,
face-600-200-at-2.jpeg 600w 200h 2x,
face-icon.png 200w 200h"&gt;</code></pre>
<p>Of course, this can be improved, and must be. This isn&#8217;t just about aesthetics. If the syntax is too weird, it will be used wrongly. As <a href="https://twitter.com/#!/rem/status/202306584880234496">Dr Remy wrote</a>, &#8220;Good to see authors have <em>another</em> microsyntax to learn. It&#8217;s not like they had any trouble with vendor-prefixes.&#8221;</p>
	
<p>The second problem is that authors don&#8217;t want to relinquish control. There are questions of art direction (see the section headed <a href="http://css-tricks.com/which-responsive-images-solution-should-you-use/">Do I care about art direction?</a>), and many remain unconvinced that the Apple suggestion addresses that; proponents of srcset are convinced that <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-May/035907.html">it does address those use cases</a>. </p> 
<p>Debate continues, with a <a href="http://www.cartoonstock.com/directory/e/exchange_of_views.asp">full and frank exchange of views</a>. There are understandably <a href="http://timkadlec.com/2012/05/wtfwg/">hurt feelings</a>, too, because some of those who laboured in the Community Group feel that <a href="http://www.alistapart.com/articles/responsive-images-and-web-standards-at-the-turning-point/">their wishes and work have been ignored</a>.</p> 
<p>As one of those who proposed &lt;picture&gt;, I have a degree of attachment to it. That&#8217;s ego. (In fact, I&#8217;d be delighted if it were called the &lt;yayBruce&gt; element, but I&#8217;m resigned to the unfairness of life.) But I don&#8217;t really care which syntax makes the spec, as long as it addresses the majority of use cases and it is usable by authors. I&#8217;m just glad we&#8217;re discussing the adaptive image problem at all.</p>
<p>So, get involved. Read the discussions and say your piece. And once the dust has settled and the specification is looking stable, we Doctors will write up our diagnosis.</p> <div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/html5-briefing-notes-journalists-analysts/" rel="bookmark" class="crp_title">HTML5: briefing notes for journalists and analysts</a></li><li><a href="http://html5doctor.com/html5-simplequiz-6-zeldmans-fat-footer/" rel="bookmark" class="crp_title">HTML5 Simplequiz 6: Zeldman&#8217;s fat footer</a></li><li><a href="http://html5doctor.com/getusermedia/" rel="bookmark" class="crp_title">It&#8217;s Curtains for Marital Strife Thanks to getUserMedia</a></li><li><a href="http://html5doctor.com/why-designers-should-care-about-html5/" rel="bookmark" class="crp_title">Why designers should care about HTML5</a></li><li><a href="http://html5doctor.com/html5-simplequiz-4-figures-captions-and-alt-text/" rel="bookmark" class="crp_title">HTML5 Simplequiz #4: figures, captions and alt text</a></li></ul></div><p><a href="http://html5doctor.com/html5-adaptive-images-end-of-round-one/" rel="bookmark">HTML5 adaptive images: end of round one</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on May 16, 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/html5-adaptive-images-end-of-round-one/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>The contenteditable attribute</title>
		<link>http://html5doctor.com/the-contenteditable-attribute/</link>
		<comments>http://html5doctor.com/the-contenteditable-attribute/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 15:10:16 +0000</pubDate>
		<dc:creator>Jack Osborne</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[contenteditable]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3796</guid>
		<description><![CDATA[<p>For some time now, we’ve been using various technologies to edit and store text within a web browser. Now with the <code>contenteditable</code> attribute, things have got a whole lot easier. In this article, I’ll tell you what this attribute is for, how it works, and how we can take things further.</p>
]]></description>
			<content:encoded><![CDATA[<p>For some time now, we’ve been using various technologies to edit and store text within a web browser. Now with the <code>contenteditable</code> attribute, things have got a whole lot easier. In this article, I’ll tell you what this attribute is for, how it works, and how we can take things further.</p>

<section id="basics">
  <h2>The Basics <a href="#basics" class="permalink">#</a></h2>

  <p>First, let’s check out the spec:</p>

  <blockquote>
    <p>The <code>contenteditable</code> attribute is an enumerated attribute whose keywords are the empty string, true, and false. The empty string and the true keyword map to the true state. The false keyword maps to the false state. In addition, there is a third state, the inherit state, which is the missing value default (and the invalid value default).</p>
    <footer>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable" title="contenteditable attribute — HTML5">WHATWG</a></cite></footer>
  </blockquote>

  <p>The <code>contenteditable</code> attribute was mainly intended for providing an in-browser rich-text or WYSIWYG experience. You’ve likely seen this sort of thing in blog-based authoring tools like Symphony or sites like Flickr where you can begin editing page content simply by clicking in a given area.</p>

  <p>As mentioned above, <code>contenteditable</code> has three possible states:</p>

  <dl>
    <dt><code>contenteditable=""</code> or <code>contenteditable="true"</code></dt>
    <dd>Indicates that the element is editable.</dd>

    <dt><code>contenteditable="false"</code></dt>
    <dd>Indicates that the element is not editable.</dd>

    <dt><code>contenteditable="inherit"</code></dt>
    <dd>Indicates that the element is editable if its immediate parent element is editable. This is the default value.</dd>
  </dl>

  <p>When you add <code>contenteditable</code> to an element, the browser will make that element editable. In addition, any children of that element will also become editable unless the child elements are explicitly <code>contenteditable="false"</code>.</p>
</section>

<section id="code-example">
  <h2>Code Example <a href="#code-example" class="permalink">#</a></h2>

  <p>Here’s some example code to get us started:</p>

  <figure>
    <pre><code>&#60;div id="example-one" contenteditable="true"&#62;
&#60;style scoped&#62;
  #example-one { margin-bottom: 10px; }
  [contenteditable="true"] { padding: 10px; outline: 2px dashed #CCC; }
  [contenteditable="true"]:hover { outline: 2px dashed #0090D2; }
&#60;/style&#62;
&#60;p&#62;Everything contained within this div is editable in browsers that support &#60;code&#62;HTML5&#60;/code&#62;. Go on, give it a try: click it and start typing.&#60;/p&#62;
&#60;/div&#62;
    </code></pre>
    <figcaption>Putting it together</figcaption>
  </figure>
</section>

<section id="live-examples">
  <h2>Live examples <a href="#live-examples" class="permalink">#</a></h2>
  
  <p>Here are two basic-but-live examples showing what you can do with <code>contenteditable</code>.</p>
  
  <section id="first-example">
    <h3>Example One <a href="#first-example" class="permalink">#</a></h3>
  
    <div id="example-one" contenteditable="true">
      <figure>
        <style scoped>
          #example-one { margin: 1.5em 0; }
          [contenteditable="true"] { padding: 10px; outline: 2px dashed #CCC; }
          [contenteditable="true"]:hover { outline: 2px dashed #0090D2; }
        </style>
        <p>Everything contained within this div is editable in browsers that support <code>HTML5</code>. Go on, give it a try: click it and start typing.</p>
        <figcaption>Live text editing</figcaption>
      </figure>
    </div>

    <p>I’ve used CSS to create an obvious visual cue that this area of text is different from the rest. Note that I’ve future-proofed this with <code>&#60;style scoped&#62;</code>, which <a href="http://html5doctor.com/the-scoped-attribute/">I covered in my previous article</a>.</p>
  </section>
  
  <section id="second-example">
    <h3>Example Two <a href="#second-example" class="permalink">#</a></h3>
  
    <p><a href="http://twitter.com/chriscoyier">Chris Coyier</a> of CSS-Tricks pointed out that you can let your users <a href="http://css-tricks.com/show-and-edit-style-element/">edit the CSS</a> in real-time. Because the <code>&lt;style&gt;</code> element is set to <code>display: none</code> by the user agent, we need to set it to <code>block</code> for this code to work.</p>

    <p>Try editing the <code>CSS</code> below:</p>

    <div id="example-two" contenteditable="true">
      <figure>
        <div id="style-block">
          <style contenteditable>
          #example-two {
          background: #fff;
          color: #444;
          }
          [contenteditable="true"]{
          padding: 10px;
          outline: 3px dashed #CCC;
          }
          [contenteditable="true"]:hover{
          background: rgba(255, 255, 153, 1);
          outline: 3px dashed #0090D2;
          }
          </style>
        </div>
        <figcaption>Live CSS editing</figcaption>
      </figure>
    </div>
  </section>
</section>

<section id="browser-support">
  <h2>Browser Support <a href="#browser-support" class="permalink">#</a></h2>
  
  <p>Browser support for <code>contenteditable</code> is surprisingly good:</p>
  
  <table class="wide">
    <caption>Browser Support for <code>contenteditable</code></caption>
    <thead>
      <tr>
        <th scope="col">Browser</th>
        <th scope="col">Version</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">Chrome</th>
        <td>4.0+</td>
      </tr>
      <tr>
        <th scope="row">Safari</th>
        <td>3.1+</td>
      </tr>
      <tr>
        <th scope="row">Mobile Safari</th>
        <td>5.0+</td>
      </tr>
      <tr>
        <th scope="row">Firefox</th>
        <td>3.5+</td>
      </tr>
      <tr>
        <th scope="row">Opera</th>
        <td>9.0+</td>
      </tr>
      <tr>
        <th scope="row">Opera Mini/Mobile</th>
        <td>N/A</td>
      </tr>
      <tr>
        <th scope="row">Internet Explorer</th>
        <td>5.5+</td>
      </tr>
      <tr>
        <th scope="row">Android</th>
        <td>3.0+</td>
      </tr>
    </tbody>
  </table>

  <p>We have to give credit where it’s due and point out that Internet Explorer has supported this attribute since IE5.5. In fact, a very early iteration of <code>contenteditable</code> was <a href="http://msdn.microsoft.com/en-us/library/ms537837(VS.85).aspx">designed and implemented by Microsoft in July 2000</a>.</p>

  <p>For a more in-depth compatibility table, visit <a href="http://caniuse.com/contenteditable">When Can I Use…</a>.</p>
</section>

<section id="storing-changes">
  <h2>Storing the Changes <a href="#storing-changes" class="permalink">#</a></h2>

  <p>For this section, I went straight to Doctor Remy for help, as he is much more knowledgeable than me when it comes to <del>storing your data</del> everything.</p>

  <blockquote>
    <p>Depending on the complexity of your editable block, your code could be listening for the enter key (keyCode 13) to save the changes, and the escape key (keyCode 27) to undo the changes.</p>

    <p>When the user hits enter (assuming it’s a single line of editable content), it would grab the innerHTML of the editable field and send an Ajax post to your server with the change.</p>

    <p>A simple example of this can be seen on JS Bin: <a href="http://jsbin.com/owavu3">contenteditable saving to Ajax</a></p>

    <footer>— <cite><a href="http://html5doctor.com/author/remys/" title="Remy Sharp on storing content changes with the contenteditable attribute">Remy Sharp</a></cite></footer>
  </blockquote>
</section>

<section id="conclusion">
  <h2>Conclusion <a href="#conclusion" class="permalink">#</a></h2>
  
  <p>We’ve repeated the phrase “paving the cowpaths” all over this site, and I’m mentioning it again with the introduction of the <code>contenteditable</code> attribute. The spec finally makes official something that’s been implemented by browser makers for years.</p>

  <p>Although this is one of the lesser-known new attributes, I bet you’ll find yourself using it more often than you would think.</p>

  <p>Imagine being able to simply click a block of content and start making changes instantly: making quick corrections to an article in-place, allowing users to edit their comments, or even building spreadsheets within company applications that aren’t hooked up to any sort of back-end user interface.</p>

  <p>If you can think of other uses for this attribute, then head on down to the comments section and tell us where else you think this could be implemented.</p>
</section>

<section id="related-reading">
  <h2>Related Reading <a href="#related-reading" class="permalink">#</a></h2>
  
  <ul>
    <li><a href="http://blog.whatwg.org/the-road-to-html-5-contenteditable#what">What is <code>contenteditable</code>?</a></li>
    <li><a href="http://css-tricks.com/expanding-images-html5/">Expanding Images Using HTML5’s <code>contenteditable</code></a></li>
  </ul>
</section><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/native-drag-and-drop/" rel="bookmark" class="crp_title">Native Drag and Drop</a></li><li><a href="http://html5doctor.com/css3-pseudo-classes-and-html5-forms/" rel="bookmark" class="crp_title">CSS3 Pseudo-Classes and HTML5 Forms</a></li><li><a href="http://html5doctor.com/the-output-element/" rel="bookmark" class="crp_title">The output element</a></li><li><a href="http://html5doctor.com/ol-element-attributes/" rel="bookmark" class="crp_title">The <code>ol</code> Element and Related Attributes: <code>type</code>, <code>start</code>, <code>value</code>, and <code>reversed</code></a></li><li><a href="http://html5doctor.com/why-designers-should-care-about-html5/" rel="bookmark" class="crp_title">Why designers should care about HTML5</a></li></ul></div><p><a href="http://html5doctor.com/the-contenteditable-attribute/" rel="bookmark">The contenteditable attribute</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on January 10, 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/the-contenteditable-attribute/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Goodbye time, datetime, and pubdate. Hello data and value.</title>
		<link>http://html5doctor.com/time-and-data-element/</link>
		<comments>http://html5doctor.com/time-and-data-element/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 16:53:08 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Specification Changes]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=4071</guid>
		<description><![CDATA[<p>While HTML5 is stable and being implemented we’re still not past losing (or gaining) an element, as demonstrated by the removal of <code>&#60;time&#62;</code> and the addition of <code>&#60;data&#62;</code>. Rather than jumping into the ensuing brouhaha, we’ve spent some time figuring out what this really means. In short? Well… it’s complicated.</p>]]></description>
			<content:encoded><![CDATA[<p class=disclaimer>Please note that since this was written, <code>&lt;time&gt;</code>, <code>datetime</code> and (possibly) <code>pubdate</code> have been reinstated, and made more powerful. Doctor Bruce has the low-down in his blogpost <a href="http://www.brucelawson.co.uk/2012/best-of-time/">The best of &lt;time&gt;s</a>. We preserve this merely to show our grandchildren that we played a role in the Time Wars.</p>
<p>We’ve come a long way in the HTML5 specification’s steady march towards ratification and implementation. The WHATWG’s energy has recently been more on <em>post</em>-HTML5 features that are being added to “<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/" title="HTML Standard">HTML The Living Standard</a>”, plus tidying up HTML5 for Last Call. However we’re still not past losing (or gaining) an element, with last week seeing <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=13240" title="Bug 13240 &ndash; Consider replacing &lt;time&gt; with &lt;data&gt;">the removal of <code>&lt;time&gt;</code> and the addition of <code>&lt;data&gt;</code></a>.</p>

<div id="2011-11-13" class="callout changed-block">
<p><em><time datetime="2011-11-13T23:36:24+09:00">2011-11-13</time>:</em> As per the <a href="http://lists.w3.org/Archives/Public/public-html/2011Nov/0098.html" title="HTML5 spec reverted to cvs r1.5431, svn r6782 [was: Revert request  for r6783] from Michael[tm] Smith on 2011-11-10 (public-html@w3.org from November 2011)">HTML Working Group Chairs request</a>, the <a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-time-element" title="4.6 Text-level semantics &#8212; HTML5">W3 HTML5 Editor’s Draft spec</a> has been reverted to include <code>&lt;time&gt;</code>. Note this means it no longer includes <code>&lt;data&gt;</code>. The <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-data-element" title="4.6 Text-level semantics &#8212; HTML Standard">WHATWG HTML: Living Standard spec</a> is currently the opposite, still retaining <code>&lt;data&gt;</code> but with no <code>&lt;time&gt;</code>. According to <a href="http://blog.whatwg.org/weekly-tpac-2011" title="The WHATWG Blog  — WHATWG Weekly: TPAC 2011">Anne Van Kesteren’s post on the WHATWG Weblog</a>, <code>&lt;time&gt;</code> will return to the WHATWG spec taking into account <a href="http://wiki.whatwg.org/wiki/Time_element" title="Time element - WHATWG Wiki">new use cases on the WHATWG Wiki</a>.</p>
<p>TL;DR — it looks like <code>&lt;time&gt;</code> will remain, probably with more permissive <code>datetime</code>s, and <code>&lt;data&gt;</code> will also remain, but it’ll take a little while before the dust settles.</p>
</div>

<p><code>&lt;time&gt;</code> was originally added to allow dates and times to be machine readable, via the <code>datetime</code> attribute. This gives us human-readable content (“yesterday”) plus hidden machine-readable content (“2011-11-02”) with no accessibility problems. It allows for e.g. browsers to offer to localise dates. The <code>pubdate</code> attribute indicating an article’s date of publication was added for HTML to Atom conversion (also removed from HTML5 in this change), and would make it easy for search engines to sort by date. Having <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#dates-and-times">permitted dates and times specified in HTML5</a> (a subset of ISO 8601) allows a validator to check a <code>datetime</code> value is valid.</p>

<p><code>&lt;time&gt;</code> has been one of the easier elements to understand for authors, as it’s semantically obvious. By comparison the <a href="http://microformats.org/wiki/value-class-pattern">microformats Class-Value pattern</a> for datetimes is clunky.</p>

<p>HTML5 <code>&lt;time&gt;</code> element:</p>
<pre class="callout"><code>&lt;time class="dtstart" datetime="2011-10-05T09:00Z"&gt;9am on October 5&lt;/time&gt;</code></pre>

<p>Microformats Value-Class pattern:</p>
<pre class="callout"><code>&lt;span class="dtstart"&gt;&lt;abbr class="value" title="09:00"&gt;9am&lt;/abbr&gt; on &lt;abbr class="value" title="2011-10-05"&gt;October 5&lt;/abbr&gt;&lt;/span&gt;</code></pre>

<p><code>&lt;time&gt;</code> has been pretty widely used for weblog article publication dates, and has made it into WordPress and Drupal <del title="Removing due to lack of evidence, as the example I found can also be explained by Google just munging text for patterns.">plus being used by Google for search results</del>.</p>

<p><a href="http://wiki.whatwg.org/wiki/Time">The issues raised about <code>&lt;time&gt;</code></a> by authors were mainly that it didn’t do <em>everything</em>: it didn’t cover ancient and vague times, time durations, and there was no “last updated” attribute equivalent to <code>pubdate</code>. The other problem is there are a bunch of other less common but similar kinds of data that would also benefit from being machine readable and validatable, such as weights and prices. Minting a new element for each one would (arguably) be a lot of work, so Ian Hickson has added a generic element for these use cases instead — the <code>&lt;data&gt;</code> element, with a required <code>value</code> attribute.</p>

<blockquote>
<p>The data element represents its contents, along with a machine-readable form of those contents in the value attribute.</p>
<footer>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-data-element" title="4.6 Text-level semantics &#8212; HTML Standard">WHATWG HTML Living Standard specification</a></cite> </footer>
</blockquote>

<p>The <code>value</code> attribute contains the machine-readable equivalent of the element’s content. The <code>&lt;data&gt;</code> element can be used as-is as an element equivalent of <code>data-*</code> for marking up private data for scripts (although without the dataset <abbr>API</abbr>). It can also be used in conjunction with <a href="http://html5doctor.com/microdata/" title="Extending HTML5 — Microdata | HTML5 Doctor">microdata vocabularies</a> (and potentially <a href="http://html5doctor.com/microformats/" title="Extending HTML5 — Microformats | HTML5 Doctor">microformats</a>), in which case the format of the <code>value</code> attribute is specified by the vocabulary.</p>

<p>This is a welcome addition as it gives us an easy way to duplicate microformats’ Value-Class pattern for more than just the datetimes <code>&lt;time&gt;</code> allowed. However as part of introducing <code>&lt;data&gt;</code>, <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=13240"><code>&lt;time&gt;</code> together with <code>datetime</code> and <code>pubdate</code> have been dropped</a>.</p>

<p>This is controversial, with <a href="http://www.brucelawson.co.uk/2011/goodbye-html5-time-hello-data/">our own Dr Bruce writing</a>:</p>

<blockquote>
<p>I think this is a bad decision</p>
</blockquote>

<p><a href="http://lists.w3.org/Archives/Public/public-html/2011Oct/0163.html">Steve Faulkner has requested this change be reverted</a>, and <a href="https://twitter.com/#!/search/occupyhtml5">comments on the Twitters</a> and blogs (<a href="http://www.brucelawson.co.uk/2011/goodbye-html5-time-hello-data/#comments">Bruce</a>, <a href="http://www.webmonkey.com/2011/10/html5-drops-the-time-element/#comments">WebMonkey</a>, <a href="http://www.zeldman.com/2011/10/31/goodbye-html5-element/#comments">Zeldman</a>) have been mostly ranging from shock to outrage.</p>

<p>This is because while <code>&lt;time&gt;</code> is semantically obvious, <code>&lt;data&gt;</code> is seen as an equivalent to <code>&lt;div&gt;</code> or <code>&lt;span&gt;</code>. However, “semantics for the sake of it” isn’t enough to justify being in the spec, despite the benefits. Another reason for the dismay is many people have had trouble pushing to use HTML5, and having an element removed gives fuel to anyone arguing HTML5 isn’t suitable for production.</p>

<section id="problems">
<h2>What’s wrong with this picture <a class="permalink" href="#problems">#</a></h2>

<p>In <a href="http://meiert.com/en/blog/20111026/on-semantics-in-html/">On Semantics in HTML</a>, <a href="https://twitter.com/j9t">Jens Meiert</a> lists five types of semantics in HTML markup, ordered from most to least meaningful:</p>

<ul>
<li>Standards bodies: elements, attributes</li>
<li>Communities: microdata and microformats vocabularies, <abbr title="plain old semantic HTML">POSH</abbr> formats</li>
<li>Common sense: functional ID and class names</li>
<li>Generic names</li>
<li>Obfuscated, random, or presentational names</li>
</ul>

<p>Demoting datetimes from spec-specified to vocabulary-specified has several effects. For one, it’s more complex. Compare these two examples using <code>&lt;time&gt;</code> and <code>&lt;data&gt;</code> respectively:</p>

<p>Using <code>&lt;time&gt;</code>:</p>
<pre class="callout"><code>&lt;article&gt;
 …
 &lt;footer&gt;Published <mark>&lt;time pubdate datetime="2011-11-03"&gt;</mark>today<mark>&lt;/time&gt;</mark>.&lt;/footer&gt;
&lt;/article&gt;
</code></pre>

<p>Using <code>&lt;data&gt;</code> plus the <a href="http://schema.org/BlogPosting" title="BlogPosting  - schema.org">BlogPosting schema.org microdata vocabulary</a>:</p>
<pre class="callout"><code>&lt;article <mark>itemscope itemtype="http://schema.org/BlogPosting"</mark>&gt;
 …
 &lt;footer&gt;Published <mark>&lt;data itemprop="datePublished" value="2011-11-03"&gt;</mark>today<mark>&lt;/data&gt;</mark>.&lt;/footer&gt;
&lt;/article&gt;
</code></pre>

<p>While Google would no doubt love everyone to start using schema.org vocabularies, it’s a big increase in complexity. Adding <code>&lt;time datetime="…" pubdate&gt;</code> is fairly straightforward — learning and implementing microdata plus an appropriate schema.org vocabulary … not so much. Because of this fewer people will implement machine-readable article published dates.</p>

<p>To make matters worse, Google’s Rich Snippets Testing Tool (so presumably Google Search too) understandably <a href="http://www.google.com/webmasters/tools/richsnippets?url=http%3A%2F%2Foli.jp%2Ftest%2Fmicrodata%2Fblogposting.html&amp;view=" title="Webmaster Tools - Rich Snippets Testing Tool">does not yet know about <code>&lt;data&gt;</code></a>. This means if you use <code>&lt;data&gt;</code> to replace <code>&lt;time&gt;</code> now, Google will only see the <em>human</em>-readable text. <code>&lt;data itemprop="datePublished" value="2011-11-03"&gt;today&lt;/data&gt;</code> is interpreted as <code>datePublished = <mark>today</mark></code>, not <code>datePublished = 2011-11-03</code>.</p>

<p>Also, now that specifying a datetime is not part of HTML5 we (presumably) can no longer validate datetime values using the HTML5 validator. Instead our only option is currently doing the two-step with Google’s Rich Snippets Testing Tool. Ironically as <a href="http://schema.org/Date" title="Date  - schema.org">schema.org defined dates using ISO 8601</a>, the imprecise dates and durations requested for <code>&lt;time&gt;</code> are now valid for <code>datePublished</code>, even though <code>pubdate</code> is the one usage of <code>datetime</code> everyone agreed on.</p>

<!-- /#problems --></section>

<section id="swings-roundabouts">
<h2>Pros &amp; Cons <a class="permalink" href="#swings-roundabouts">#</a></h2>

<p>Ian Hickson and, it seems, browser makers in general are for this change, whereas authors are in general against it (ahem, <a href="http://www.w3.org/TR/html-design-principles/#priority-of-constituencies" title="HTML Design Principles">priority of constituencies</a>). A couple of options would be:</p>

<ol>
<li>Scrap <code>&lt;data&gt;</code> and allow the <code>value</code> attribute on any element</li>
<li>Add a <code>type</code> attribute to <code>&lt;data&gt;</code> to make it more semantic</li>
<li>Bring back <code>&lt;time&gt;</code></li>
</ol>

<p>Unfortunately there are pros and cons for each of these options:</p>

<section id="value-everywhere">
<h3>Allow <code>value</code> on any element <a class="permalink" href="#value-everywhere">#</a></h3>

<p>This conflicts with microdata, where the values of some elements are their URLs rather than their content. For example, currently <code>&lt;img itemprop="photo" src="http://oli.jp/photo.jpg"&gt;</code> gives the microdata output of <code>photo = "http://oli.jp/photo.jpg"</code>. Adding <code>value</code> to the mix means there’d be two machine-readable values, so authors would need to know <a href="http://html5doctor.com/microdata/#itemprop-value" title="Extending HTML5 — Microdata | HTML5 Doctor">which elements couldn’t accept <code>value</code></a>.</p>

<!-- /#value-everywhere --></section>

<section id="type-attribute">
<h3>Add a <code>type</code> attribute to <code>&lt;data&gt;</code> <a class="permalink" href="#type-attribute">#</a></h3>

<p>This means the HTML5 specification has to specify each approved <code>type</code> value. While not as much work for implementers as a new element for each type of data, it’s still a bunch of work if the browsers actually do anything with that knowledge (like auto-converting <code>type="money"</code> into your currency). If <code>type</code> is required it also limits <code>&lt;data&gt;</code> to the types that are defined.</p>

<!-- /#type-attribute --></section>

<section id="more-time">
<h3>Bring back <code>&lt;time&gt;</code> <a class="permalink" href="#more-time">#</a></h3>

<p>The easiest way to make everyone happy is to keep <code>&lt;time&gt;</code> <em>in addition to</em> adding <code>&lt;data&gt;</code>. However the cons for this are we’d have two confusingly similar but not always interchangeable ways to mark up datetimes, potentially with different rules on what’s a valid datetime. For example, we’d need to mark up an article’s published date and updated date using different syntax. Special cases and exceptions make things harder to teach and learn.</p>

<!-- /#more-time --></section>

<!-- /#swings-roundabouts --></section>


<section id="conclusion">
<h2>Conclusion <a class="permalink" href="#conclusion">#</a></h2>

<p>While our private conversation between doctors about this has tended towards the <abbr>WTF</abbr> end of the spectrum, I’m personally up in the air about it. Despite the easy response (“bring back <code>&lt;time&gt;</code>!”), this is one of those thorny problems where there’s no simple right answer. <abbr>WHATWG</abbr> is performing a delicate balancing act: pragmatically adding only features that have a lot of value, and <a href="http://wiki.whatwg.org/wiki/FAQ#Is_there_a_process_for_removing_bad_ideas_from_a_specification.3F" title="FAQ - WHATWG Wiki">removing any that don’t make the grade</a>. In this case Hixie decided the cons of <code>&lt;time&gt;</code> (and of removing it from HTML5) outweighed the pros, and <code>&lt;data&gt;</code> is the result.</p>

<p>The one thing that bothers me about Hixie’s argument is that while datetimes are similar to other types of data that <code>&lt;data&gt;</code> now lets us mark up, they’re orders of magnitude more common on the web. Regardless of how it’s marked up, almost all weblog posts have the published date, and the majority of sites have a copyright date in the footer. In these use cases <code>&lt;time&gt;</code> was perfect, and definitely covered the 80%.</p>

<p>In my ideal world I’d like <code>&lt;time&gt;</code> to return, with the addition of a “<code>pubupdate</code>” attribute, and for all <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#dates-and-times" title="2.5 Common microsyntaxes &#8212; HTML Standard">dates and times that fall inside HTML5’s definition</a> to use <code>&lt;time&gt;</code>. For datetimes that <code>&lt;time&gt;</code> currently doesn’t cover, and for general use, we’d have <code>&lt;data&gt;</code>. Then again, I’m not sure I’d want to try teaching such intricacies to someone.</p>

<p>What do you think about this? While you’re welcome to just jump on the hogpile, I’d be interested to hear people consider all the pros and cons, and try to come up with a better (or less problematic) solution.</p>

<!-- /#conclusion --></section>

<footer><small>(Thanks to <a href="https://twitter.com/estellevw">Estelle Weyl</a>, <a href="https://twitter.com/annevk">Anne van Kesteren</a> and <a href="https://twitter.com/foolip">Philip Jägenstedt</a> for their feedback.)</small></footer><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/the-time-element/" rel="bookmark" class="crp_title">The time element (and microformats)</a></li><li><a href="http://html5doctor.com/microdata/" rel="bookmark" class="crp_title">Extending HTML5 — Microdata</a></li><li><a href="http://html5doctor.com/microformats/" rel="bookmark" class="crp_title">Extending HTML5 — Microformats</a></li><li><a href="http://html5doctor.com/html5-seo-search-engine-optimisation/" rel="bookmark" class="crp_title">HTML5 and Search Engine Optimisation (SEO)</a></li><li><a href="http://html5doctor.com/lets-talk-about-semantics/" rel="bookmark" class="crp_title">Let&#8217;s Talk about Semantics</a></li></ul></div><p><a href="http://html5doctor.com/time-and-data-element/" rel="bookmark">Goodbye time, datetime, and pubdate. Hello data and value.</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on November 2, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/time-and-data-element/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>The scoped attribute</title>
		<link>http://html5doctor.com/the-scoped-attribute/</link>
		<comments>http://html5doctor.com/the-scoped-attribute/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 13:30:57 +0000</pubDate>
		<dc:creator>Jack Osborne</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[semantics]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3634</guid>
		<description><![CDATA[<p>The scoped attribute for the style element allows you to include styles mid-document that targets a specific element and its children. Depending upon how you look at this, it’ll either be a godsend or a curse. Once you’ve reached the end of this article, I hope you can form your own opinion.</p>]]></description>
			<content:encoded><![CDATA[<p>The <code>scoped</code> attribute for the <code>&lt;style&gt;</code> element allows you to include styles mid-document that targets a specific element and its children. Depending upon how you look at this, it’ll either be a godsend or a curse. Once you’ve reached the end of this article, I hope you can form your own opinion.</p>

<p>Let’s take a quick look at the spec:</p>

<blockquote>
<p>The <code>scoped</code> attribute is a boolean attribute. If set, it indicates that the styles are intended just for the subtree rooted at the style element’s parent element, as opposed to the whole Document.</p>
<footer>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-style-scoped" title="Scoped attribute — HTML5">WHATWG</a></cite></footer>
</blockquote>

<section id="bad">
<h2>Isn’t this bad practice?</h2>
<p>For years, we’ve been told (and have actively told others) to separate content and presentation layers. So why would we introduce something that seems to go against everything we’ve been preaching?</p>

<p>The separation of these layers is still vitally important, but let’s look at a few use cases to shed some light on why this attribute has been introduced. Scoped style provides a W3C-approved way to:</p> 

<ul>
  <li>Add one-off CSS styles.</li>
  <li>Add user-defined styles to wiki or CMS content.</li>
  <li>Add theme-defined styles via CMS plugins.</li>
  <li>Keep syndicated content together (e.g., keeping example code together with the example).</li>
</ul>
</section>

<section id="how-does">
<h2>How does it work?</h2>
<p>In this section, I’ll show you how this new attribute will work when it gets rolled out to browsers.</p>

<section id="starting">
<h3>Our starting point</h3>

<p>We’ll be using the following code sample as a starting point:</p>

<pre><code>&#60;article&#62;
  &#60;h1&#62;Style Scoped&#60;/h1&#62;
  &#60;p&#62;The scoped attribute for the style element will eventually allow for you to include style elements mid-document. To do this, you must mark up your style element with the scoped attribute.&#60;/p&#62;
  &#60;section&#62;
    &#60;h2&#62;How does it work?&#60;/h2&#62;
    &#60;p&#62;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.&#60;/p&#62;
  &#60;/section&#62;
&#60;/article&#62;</code></pre>

<p>This is a basic example, with two headings and two paragraphs set within the article element.</p>
</section>

<section id="addingscope">
<h3>Adding the <code>scoped</code> attribute</h3>

<p>In the next example, we’ll change the foreground color of the second paragraph to red (from whatever was defined in the master CSS file):</p>

<pre><code>&#60;article&#62;
  &#60;h1&#62;Style Scoped&#60;/h1&#62;
  &#60;p&#62;The scoped attribute for the style element will eventually allow for you to include style elements mid-document. To do this, you must mark up your style element with the scoped attribute.&#60;/p&#62;
  &#60;section&#62;
    &#60;style <mark>scoped</mark>&#62;
      p { color: red; }
    &#60;/style&#62;
    &#60;h2&#62;How does it work?&#60;/h2&#62;
    &#60;p&#62;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.&#60;/p&#62;
  &#60;/section&#62;
&#60;/article&#62;</code></pre>

<aside class="sidenote"><p>It’s worth noting that the <code>scoped</code> attribute can’t be the first attribute of the body element. I also received a validation error using <code>&#60;body style="..."&#62;</code>.</p></aside>

<p id="example">This screenshot shows how things might render in the browser:</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/09/scoped1.gif" alt="" title="scoped" width="526" height="297" class="alignnone size-full wp-image-3735" />
<figcaption>How the <code>scoped</code> attribute will render</figcaption>
</figure>
</section>
</section>

<section id="link">
<h2>Can I apply <code>scoped</code> to &#60;link&#62;?</h2>
<p>While I was writing this article, Dr. Rich asked whether it was possible to add this attribute to <code>&lt;link&gt;</code> elements. Turns out you can’t, but I stumbled across this tidbit in the WHATWG mailing list:</p>

<blockquote>
  <p>You can use &#60;style scoped&#62;@import url(whatever);&#60;/style&#62;</p>
  <p>And this even enables you to add some specific styles ([be they embedded] or from another external sheet) on a per-use basis if the need arises. For example, a long dissertation relying on many quotes may benefit from adding stronger visual highlights on the &#60;em&#62; elements within the last quote to reinforce the final conclusion.</p>
  <footer>— <cite><a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-March/031049.html"> Eduard Pascuals WHATWG mailing list response #031049</a></cite></footer>
</blockquote>
</section>

<section id="compatibility">
<h2>Backwards compatibility</h2>	
<p>Unfortunately, scoped style isn’t all puppy dogs and kittens.</p>

<p>Since this newly introduced attribute isn’t understood by current browsers, CSS rules in <code>&#60;style scoped&#62;</code> are just added to the page’s CSS. Therefore, if you were to include a <code>scoped</code> style block mid-page, its declarations would be applied to every matching element in the document, regardless of whether the element were inside or outside of the scope’s range.</p>

<p>For the sake of backwards compatibility, Louis Lazaris has suggested <a href="http://www.impressivewebs.com/scoped-styles-html5/">a brand new element called <code>&#60;scopedstyle&#62;</code></a>. This new element would only be recognised by supporting browsers and ignored by everything else. This way, scoped styles wouldn’t be added to the whole document. Instead, the browser would just throw away the unrecognised <code>&lt;scopedstyle&gt;</code> element and move on.</p>
</section>

<section id="support">
<h2>Browser support</h2>

<table class="wide">
<caption>Browser support for <code>&lt;style scoped&gt;</code> <i>(as of <time datetime="2011-09-06">6th September, 2011</time>)</i></caption>
<thead>
<tr>
<th scope="col">Browser</th>
<th scope="col">Support</th>
</tr>
</thead>
<tbody>
<tr>
  <th scope="row">Chrome 13</th>
  <td>No</td>
</tr>
<tr>
  <th scope="row">Safari 5</th>
  <td>No</td>
</tr>
<tr>
  <th scope="row">Firefox 6</th>
  <td>No</td>
</tr>
<tr>
  <th scope="row">Opera 11.51</th>
  <td>No</td>
</tr>
<tr>
  <th scope="row">Internet Explorer 9</th>
  <td>No</td>
</tr>
</tbody>
</table>

<p>Currently, the <code>scoped</code> attribute isn’t working in any of the browser alpha versions (Opera.Next, Mozilla Aurora, or WebKit nightly builds). There’s work in progress by <a href="https://bugs.webkit.org/show_bug.cgi?id=49142">Roland Steiner for support in WebKit</a>.</p>
</section>

<section id="using-today">
<h2>Using <code>&#60;style scoped&#62;</code> today</h2>
<p>So you’ve read this article and decided that you <em>need</em> scoped style in your life. What now? Well, just like every other new HTML5 thing, we have a polyfill for it. <a href="http://twitter.com/#!/thingsinjars">Simon Madine</a> has created a <a href="https://github.com/thingsinjars/jQuery-Scoped-CSS-plugin">jQuery scoped CSS plugin on GitHub</a>.</p>

<aside class="sidenote"><p>Please note that Oli used a wrapper <code>&lt;div&gt;</code> because of <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=13102">validation problems explained in this bug</a>.</p></aside>

<p>You could also assign a CSS prefix to target the section of your document you want to style. You’d still be able to stick your styles inline, but you’ve also provided a fallback for the older browsers. In fact, Dr. Oli has done just that on his <a href="http://html5doctor.com/blockquote-q-cite/">latest article</a>. (View source and search for <code>&#60;div class="faint"&#62;</code>.)</p>
</section>

<section id="opinions">
<h2>Opinions</h2>

<p>There’s no denying that we’re breaking backwards compatibility by introducing <code>&lt;style scoped&gt;</code>. To me, this just doesn’t make any sense. I feel this needs to be addressed by either creating a new element like <code>&lt;scopedstyle&gt;</code> or using some protective mechanism like the <code>&#60;!--</code> and <code>--&#62;</code> delimiters that have been used within <code>&lt;style&gt;</code> and <code>&lt;script&gt;</code> elements.</p>

<p>Let’s not end this article with negative sentiment, though. As with anything, it’s what you make of it. Scoped style is pretty plain vanilla, but if people abuse it, it’ll end up with a bad rap. <a href="http://html5doctor.com/author/olib/">Dr. Oli</a> has spoken at length about his love for this attribute as it allows him to have live code examples with the CSS in <code>&#60;pre&#62;</code> and also in a <code>&#60;style scoped&#62;</code> within a <code>&#60;figure&#62;</code>.</p>

<p>So now it’s time for you to express your views. What do you think about the new <code>scoped</code> attribute? Do you think it has a future? Should it be fast-tracked into the spec? Or do you think it’s a waste of time that could ultimately end up mixing our content and presentation layers together again? Let us know in the comments!</p>
</section><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/the-contenteditable-attribute/" rel="bookmark" class="crp_title">The contenteditable attribute</a></li><li><a href="http://html5doctor.com/ol-element-attributes/" rel="bookmark" class="crp_title">The <code>ol</code> Element and Related Attributes: <code>type</code>, <code>start</code>, <code>value</code>, and <code>reversed</code></a></li><li><a href="http://html5doctor.com/u-element/" rel="bookmark" class="crp_title">The return of the u element</a></li><li><a href="http://html5doctor.com/the-details-and-summary-elements/" rel="bookmark" class="crp_title">The details and summary elements</a></li><li><a href="http://html5doctor.com/css3-pseudo-classes-and-html5-forms/" rel="bookmark" class="crp_title">CSS3 Pseudo-Classes and HTML5 Forms</a></li></ul></div><p><a href="http://html5doctor.com/the-scoped-attribute/" rel="bookmark">The scoped attribute</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on September 13, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/the-scoped-attribute/feed/</wfw:commentRss>
		<slash:comments>73</slash:comments>
		</item>
		<item>
		<title>Avoiding common HTML5 mistakes</title>
		<link>http://html5doctor.com/avoiding-common-html5-mistakes/</link>
		<comments>http://html5doctor.com/avoiding-common-html5-mistakes/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 13:38:05 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[figure]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[hgroup]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[nav]]></category>
		<category><![CDATA[section]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3494</guid>
		<description><![CDATA[<p>Between curating sites for the HTML5 gallery and answering readers’ questions here at HTML5 Doctor, I see a host of HTML5 sites and their underlying markup. In this post, I’ll show you some of the mistakes and poor markup practices I often see and explain how to avoid them.</p>]]></description>
			<content:encoded><![CDATA[<p>Between curating sites for the <a href="http://html5gallery.com">HTML5 gallery</a> and answering readers’ questions here at HTML5 Doctor, I see a host of HTML5 sites and their underlying markup. In this post, I’ll show you some of the mistakes and poor markup practices I often see and explain how to avoid them.</p>

<section id="section-wrapper">
  <h2>Don’t use section as a wrapper for styling</h2>
  <p>One of the most common problems I see in people’s markup is the arbitrary replacement of <code>&lt;div&gt;</code>s with HTML5 sectioning elements — specifically, replacing wrapper <code>&lt;div&gt;</code>s (used for styling) with <code>&lt;section&gt;</code>s. In XHTML or HTML4, I would see something like this:</p>
  
  <pre><code>&lt;!-- HTML 4-style code --&gt;
&lt;div id="wrapper"&gt;
  &lt;div id="header"&gt;  
    &lt;h1&gt;My super duper page&lt;/h1&gt;
    &lt;!-- Header content --&gt;
  &lt;/div&gt;
  &lt;div id="main"&gt;
    &lt;!-- Page content --&gt;
  &lt;/div&gt;
  &lt;div id="secondary"&gt;
    &lt;!-- Secondary content --&gt;
  &lt;/div&gt;
  &lt;div id="footer"&gt;
    &lt;!-- Footer content --&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>

  <p>Now, I’m instead seeing this:</p>
  
  <pre><code>&lt;!-- Don’t copy this code! It’s wrong! --&gt;
<mark>&lt;section id="wrapper"&gt;</mark>
  &lt;header&gt;  
    &lt;h1&gt;My super duper page&lt;/h1&gt;
    &lt;!-- Header content --&gt;
  &lt;/header&gt;
  &lt;section id="main"&gt;
    &lt;!-- Page content --&gt;
  &lt;/section&gt;
  &lt;section id="secondary"&gt;
    &lt;!-- Secondary content --&gt;
  &lt;/section&gt;
  &lt;footer&gt;
    &lt;!-- Footer content --&gt;
  &lt;/footer&gt;
<mark>&lt;/section&gt;</mark></code></pre>
  
  <p>Frankly, that’s just wrong: <strong><code>&lt;section&gt;</code> is not a wrapper</strong>. <a href="http://html5doctor.com/section">The <code>&lt;section&gt;</code> element</a> denotes a semantic section of your content to help construct a <a href="http://html5doctor.com/outline">document outline</a>. It should contain a heading. If you’re looking for a page wrapper element (for any flavour of HTML or XHTML), consider applying styles directly to the <code>&lt;body&gt;</code> element as described by <a href="http://camendesign.com/code/developpeurs_sans_frontieres">Kroc Camen</a>. If you still need an additional element for styling, use a <code>&lt;div&gt;</code>. As <a href="http://html5doctor.com/div">Dr Mike explains, div isn’t dead</a>, and if there’s nothing else more appropriate, it’s probably where you really want to apply your CSS.</p>
  
  <p>With that in mind, here’s the correct way to mark up the above example using HTML5 and a couple of ARIA roles. (Note: you may need one <code>&lt;div&gt;</code> depending on your design.)</p>

  <pre><code>&lt;body&gt;
  &lt;header&gt;  
    &lt;h1&gt;My super duper page&lt;/h1&gt;
    &lt;!-- Header content --&gt;
  &lt;/header&gt;
  &lt;div role="main"&gt;
    &lt;!-- Page content --&gt;
  &lt;/div&gt;
  &lt;aside role="complementary"&gt;
    &lt;!-- Secondary content --&gt;
  &lt;/aside&gt;
  &lt;footer&gt;
    &lt;!-- Footer content --&gt;
  &lt;/footer&gt;
&lt;/body&gt;</code></pre>
    
  <p>If you’re not quite sure which element to use, then I suggest you refer to our <a href="http://html5doctor.com/flowchart">HTML5 sectioning content element flowchart</a> to guide you along your way.</p>

</section>

<section id="header-hgroup">
  <h2>Only use header and hgroup when they’re required</h2>
  
  <p>There’s no sense writing markup when you don’t have to, right? Unfortunately, I often see <code>&lt;header&gt;</code> and <code>&lt;hgroup&gt;</code> being used when there’s no need for them. You can get up to speed with our articles on <a href="http://html5doctor.com/header">the <code>&lt;header&gt;</code> element</a> and <a href="http://html5doctor.com/hgroup">the <code>&lt;hgroup&gt;</code> element</a>, but I’ll briefly summarise:</p>
  
  <ul>
    <li>The <code>&lt;header&gt;</code> element represents a group of introductory or navigational aids and usually contains the section’s heading</li>
    <li>The <code>&lt;hgroup&gt;</code> element groups a set of <code>&lt;h1&gt;</code>—<code>&lt;h6&gt;</code> elements representing a section’s heading when the heading has multiple levels, such as subheadings, alternative titles, or taglines</li>
  </ul>
  
  <section id="header-overuse">
    <h3>Overuse of header</h3>
    <p>As I’m sure you’re aware, the <code>&lt;header&gt;</code> element can be used multiple times in a document, which has popularized the following pattern:</p>

    <pre><code>&lt;!-- Don’t copy this code! No need for header here --&gt;
&lt;article&gt;
  <mark>&lt;header&gt;</mark>  
    &lt;h1&gt;My best blog post&lt;/h1&gt;
  <mark>&lt;/header&gt;</mark>
  &lt;!-- Article content --&gt;
&lt;/article&gt;</code></pre>

    <p>If your <code>&lt;header&gt;</code> element only contains a single heading element, leave out the <code>&lt;header&gt;</code>. The <code>&lt;article&gt;</code> ensures that the heading will be shown in the document outline, and because the <code>&lt;header&gt;</code> doesn’t contain multiple elements (as the definition describes), why write code when you don’t need to? Simply use this:</p>

    <pre><code>&lt;article&gt;  
  &lt;h1&gt;My best blog post&lt;/h1&gt;
  &lt;!-- Article content --&gt;
&lt;/article&gt;</code></pre>

  </section>

  <section id="hgroup-misuse">
    <h3>Incorrect use of <code>&lt;hgroup&gt;</code></h3>
    <p>On the subject of headers, I also frequently see incorrect uses of <code>&lt;hgroup&gt;</code>. You should not use <code>&lt;hgroup&gt;</code> in conjunction with <code>&lt;header&gt;</code> when:</p>

    <ul>
      <li>there’s only one child heading, or</li>
      <li>the <code>&lt;hgroup&gt;</code> would work fine on its own (i.e., without the <code>&lt;header&gt;</code>).</li>
    </ul>

    <p>The first problem looks like this:</p>

      <pre><code>&lt;!-- Don’t copy this code! No need for hgroup here --&gt;
&lt;header&gt;
  <mark>&lt;hgroup&gt;</mark>  
    &lt;h1&gt;My best blog post&lt;/h1&gt;
  <mark>&lt;/hgroup&gt;</mark>
  &lt;p&gt;by Rich Clark&lt;/p&gt;
&lt;/header&gt;</code></pre>

    <p>In that case, simply remove the <code>&lt;hgroup&gt;</code> and let the heading run free.</p>

    <pre><code>&lt;header&gt;
  &lt;h1&gt;My best blog post&lt;/h1&gt;
  &lt;p&gt;by Rich Clark&lt;/p&gt;
&lt;/header&gt;</code></pre>

    <p>The second problem is another case of including elements when they’re not necessarily required.</p>

    <pre><code>&lt;!-- Don’t copy this code! No need for header here --&gt;
&lt;header&gt;
  <mark>&lt;hgroup&gt;</mark>  
    &lt;h1&gt;My company&lt;/h1&gt;
    &lt;h2&gt;Established 1893&lt;/h2&gt;
  <mark>&lt;/hgroup&gt;</mark>
&lt;/header&gt;</code></pre>

    <p>When the only child of the <code>&lt;header&gt;</code> is the <code>&lt;hgroup&gt;</code>, why include the <code>&lt;header&gt;</code>? If you don’t have additional elements within the <code>&lt;header&gt;</code> (i.e., siblings of the <code>&lt;hgroup&gt;</code>), simply remove the <code>&lt;header&gt;</code> altogether.</p>

    <pre><code>&lt;hgroup&gt;  
  &lt;h1&gt;My company&lt;/h1&gt;
  &lt;h2&gt;Established 1893&lt;/h2&gt;
&lt;/hgroup&gt;</code></pre>

    <p>For more <code>&lt;hgroup&gt;</code> examples and explanations, read the detailed <a href="http://html5doctor.com/hgroup">article about it in the archives</a>.</p>

  </section>
  
</section>

<section id="nav-external">
  <h2>Don’t wrap all lists of links in <code>&lt;nav&gt;</code></h2>
  <p>With <a href="http://dev.w3.org/html5/html4-differences/#new-elements">30 new elements (at the time of writing)</a> introduced in HTML5, we’re somewhat spoilt for choice when it comes to creating meaningful, structured markup. That said, we shouldn’t abuse the super-semantic elements now made available to us. Unfortunately, that’s what I see happening with <code>&lt;nav&gt;</code>. The spec describes <code>&lt;nav&gt;</code> as follows:</p>
  
  <blockquote>
    <p>The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links.</p>
    
    <p>Note: Not all groups of links on a page need to be in a nav element — the element is primarily intended for sections that consist of <mark>major navigation blocks</mark>. In particular, it is common for footers to have a short list of links to various pages of a site, such as the terms of service, the home page, and a copyright page. The footer element alone is sufficient for such cases; while a nav element can be used in such cases, it is usually unnecessary.</p>
    <footer>
      <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/complete/sections.html#the-nav-element">WHATWG HTML spec</a></cite>
    </footer>
  </blockquote>
  
  <p>The key phrase is ‘major’ navigation. We could debate all day about the definition of ‘major’, but to me it means:</p>
  
  <ul>
    <li>Primary navigation</li>
    <li>Site search</li>
    <li>Secondary navigation (arguably)</li>
    <li>In-page navigation (within a long article, for example)</li>
  </ul>
  
  <p>While there isn’t any right or wrong here, a straw poll coupled with my own interpretation tells me that the following shouldn’t be enclosed by <code>&lt;nav&gt;</code>:</p>
  
  <ul>
    <li>Pagination controls</li>
    <li>Social links (although there may be exceptions where social links <em>are</em> the major navigation, in sites like <a href="http://about.me">About me</a> or <a href="http://flavours.me">Flavours</a>, for example)</li>
    <li>Tags on a blog post</li>
    <li>Categories on a blog post</li>
    <li>Tertiary navigation</li>
    <li>Fat footers</li>
  </ul>
  
  <p>If you’re unsure whether to mark up a list of links with <code>&lt;nav&gt;</code>, ask yourself this: <q>Is this major navigation?</q> To help answer the question, consider the following rules of thumb:</p>
    
  <ul>
    <li><q>Don’t use <code>&lt;nav&gt;</code> unless you think <code>&lt;section&gt;</code> would also be appropriate, with an <code>&lt;hx&gt;</code></q> — <cite><a href="http://krijnhoetmer.nl/irc-logs/whatwg/20091209#l-480">Hixie on IRC</a></cite></li>
    <li>Would you add a link to it in a ‘skip to’ block for accessibility?</li>
  </ul>
  
  <p>If the answer to these questions is ‘no’, then it’s probably not a <code>&lt;nav&gt;</code>.</p>
</section>

<section id="figure">
  <h2>Common mistakes with the figure element</h2>
  <p>Ah, <code>&lt;figure&gt;</code>. The appropriate use of this element, along with its partner-in-crime <code>&lt;figcaption&gt;</code>, is quite difficult to master. Let’s look at a few common problems I see with <code>&lt;figure&gt;</code>.</p>

  <section>
    <h3>Not every image is a figure</h3>
    <p>Earlier, I told you not to write extra code when it’s not necessary. This mistake is similar. I’ve seen sites where every image has been marked up as a <code>&lt;figure&gt;</code>. There’s no need to add extra markup around your images for the sake of it. You’re just creating more work for yourself and not describing your content any more clearly.</p>

    <p>The spec describes <code>&lt;figure&gt;</code> as being <q>some flow content, optionally with a caption, that is self-contained and is typically referenced as a single unit from the main flow of the document.</q> Therein lies the beauty of <code>&lt;figure&gt;</code>, that it can be moved away from the primary content — to a sidebar, say — without affecting the document’s flow.</p>
  
    <aside class="sidenote">
      <p>These questions are also included in the <a href="http://html5doctor.com/flowchart">HTML5 element flowchart mentioned earlier</a>.</p>
    </aside>
        
    <p>If it’s a purely presentational image and not referenced elsewhere in the document, then it’s definitely not a <code>&lt;figure&gt;</code>. Other use cases vary, but as a start, ask yourself, <q>Is this image required to understand the current context?</q> If not, it’s probably not a <code>&lt;figure&gt;</code> (an <code>&lt;aside&gt;</code>, perhaps). If so, ask yourself, <q>Could I move this to an appendix?</q> If the answer to both questions is ‘yes’, it’s probably a <code>&lt;figure&gt;</code>.</p>

  </section>
  
  <section>
    <h3>Your logo is not a figure</h3>
    <p>Segueing nicely on, the same applies to your logo. Here are a couple of snippets that I see regularly:</p>
    
    <pre><code>&lt;!-- Don’t copy this code! It’s wrong! --&gt;
&lt;header&gt;
  &lt;h1&gt;
    &lt;figure&gt;
      &lt;img src="/img/mylogo.png" alt="My company" class="hide" /&gt;
    &lt;/figure&gt;
    My company name
  &lt;/h1&gt;
&lt;/header&gt;</code></pre>
    
    <pre><code>&lt;!-- Don’t copy this code! It’s wrong! --&gt;
&lt;header&gt;  
  &lt;figure&gt;
    &lt;img src="/img/mylogo.png" alt="My company" /&gt;
  &lt;/figure&gt;
&lt;/header&gt;</code></pre>
    
    <p>There’s nothing else to say here. It’s just plain wrong. We could argue until the cows come home about whether your logo should be in an <code>&lt;h1&gt;</code>, but that’s not what we’re here for. The real issue is the abuse of the <code>&lt;figure&gt;</code> element. <code>&lt;figure&gt;</code> should be used only when referenced in a document or surrounding sectioning element. I think it’s fair to say that your logo is rarely going to be referenced in such a way. Quite simply, don’t do it. All you need is this:</p>
    
    <pre><code>&lt;header&gt;  
  &lt;h1&gt;My company name&lt;/h1&gt;
  &lt;!-- More stuff in here --&gt;
&lt;/header&gt;</code></pre>
  </section>

  <section>
    <h3>Figure can be more than an image</h3>
    <p>Another common misconception regarding <code>&lt;figure&gt;</code> is that it can only be used for images. This isn’t the case. A <code>&lt;figure&gt;</code> could be video, audio, a chart (in SVG, for example), a quote, a table, a block of code, a piece of prose, or any combination of these and much more besides. Don’t limit your <code>&lt;figure&gt;</code>s to images. Our job as web standards affectionadoes is to accurately describe the content with our markup.</p>
    
    <p>A while back, <a href="http://html5doctor.com/figure">I wrote about <code>&lt;figure&gt;</code></a> in more depth. It’s worth a read if you want more detail or need a refresher.</p>
  </section>

</section>

<section id="type-attr">
  <h2>Don’t include unnecessary type attributes</h2>
  <p>This is probably the most common problem we see in HTML5 Gallery submissions. While it isn’t really a mistake, I believe it’s best practice to avoid this pattern.</p>
  
  <p>In HTML5, there’s no need to include the <code>type</code> attribute on <code>&lt;script&gt;</code> and <code>&lt;style&gt;</code> elements. While these can be a pain to remove if they’re automatically added by your CMS, there’s really no reason to include them if you’re coding by hand or if you have tight control over your templates. Since all browsers expect scripts to be JavaScript and styles to be CSS, you don&#8217;t need this:</p>
  
  <pre><code>&lt;!-- Don’t copy this code! It’s attribute overload! --&gt;
&lt;link <mark>type="text/css"</mark> rel="stylesheet" href="css/styles.css" /&gt;
&lt;script <mark>type="text/javascript"</mark> src="js/scripts.js"&gt;&lt;/script&gt;</code></pre>
    
  <p>Instead, you can simply write:</p>
  
  <pre><code>&lt;link rel="stylesheet" href="css/styles.css" /&gt;
&lt;script src="js/scripts.js"&gt;&lt;/script&gt;</code></pre>
  
  <p>You can also reduce the amount of code you write to specify your character set, amongst other things. Mark Pilgrim’s chapter on semantics in <cite><a href="http://diveinto.html5doctor.com/semantics.html">Dive into HTML5</a></cite> explains all.</p>
  
</section>

<section id="form-attr">
  <h2>Incorrect use of form attributes</h2>
  <p>You may be aware that HTML5 has introduced a range of new attributes for forms. We’ll cover them in more detail in the coming months, but in the meantime, I’ll quickly show you a few things not to do.</p>
  
  <section>
    <h3>Boolean attributes</h3>
    
    <aside class="sidenote">
      <p>There are also boolean attributes for multimedia elements and others. The rules that I describe here apply to those elements as well.</p>
    </aside>
    
    <p>Several of the new form attributes are boolean, meaning their mere presence in the markup ensures the behaviour is set. These attributes include:</p>
    
    <ul>
      <li>autofocus</li>
      <li>autocomplete</li>
      <li>required</li>
    </ul>
    
    <p>Admittedly, I only rarely see this, but using <code>required</code> as an example, I’ve seen the following:</p>
    
    <pre><code>&lt;!-- Don’t copy this code! It’s wrong! --&gt;
&lt;input type="email" name="email" <mark>required="true"</mark> /&gt;
&lt;!-- Another bad example --&gt;
&lt;input type="email" name="email" <mark>required="1"</mark> /&gt;</code></pre>
     
    <p>Ultimately, this causes no harm. The client’s HTML parser sees the <code>required</code> attribute in the markup, so its function will still be applied. But what if you flip the code on its head and type <code>required="false"</code>?</p>
    
    <pre><code>&lt;!-- Don’t copy this code! It’s wrong! --&gt;
&lt;input type="email" name="email" <mark>required="false"</mark> /&gt;</code></pre>
    
    <p>The parser will still see the <code>required</code> attribute and implement the behaviour <em>even though you tried to tell it not to</em>. Certainly not what you wanted.</p>
    
    <p>There are three valid ways for a boolean attribute to be applied. (The second and third options only apply if you’re writing XHTML syntax.)</p>
    
    <ul>
      <li><code>required</code></li>
      <li><code>required=""</code></li>
      <li><code>required="required"</code></li>
    </ul>
    
    <p>Applying that to our above example, we would write this (in HTML):</p>

    <pre><code>&lt;input type="email" name="email" <mark>required</mark> /&gt;</code></pre>
    
  </section>
</section>

<section id="summary">
  <h2>Summary</h2>
  
  <p>It would be impossible for me to list here all the quirky markup patterns and practices I’ve come across, but these are some of the most frequently seen. What other common markup mistakes have you spotted around the web? Which areas of HTML5 require further clarification? We’d love to help get the wording or examples in the spec changed to make them a little more specific, so leave your thoughts below, and don’t forget to escape your HTML!</p>
</section>

<p><small>Thanks to Ian Devlin, Derek Johnson, Tady Walsh, the HTML5 Gallery curators, and the HTML5 Doctors for their input to this article.</small></p><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/the-hgroup-element/" rel="bookmark" class="crp_title">The hgroup element</a></li><li><a href="http://html5doctor.com/the-header-element/" rel="bookmark" class="crp_title">The header element</a></li><li><a href="http://html5doctor.com/your-questions-answered-7/" rel="bookmark" class="crp_title">Your Questions Answered #7</a></li><li><a href="http://html5doctor.com/your-questions-15/" rel="bookmark" class="crp_title">Your Questions #15</a></li><li><a href="http://html5doctor.com/the-hgroup-hokey-cokey/" rel="bookmark" class="crp_title">The hgroup hokey cokey</a></li></ul></div><p><a href="http://html5doctor.com/avoiding-common-html5-mistakes/" rel="bookmark">Avoiding common HTML5 mistakes</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 26, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/avoiding-common-html5-mistakes/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
		<item>
		<title>Extending HTML5 — Microdata</title>
		<link>http://html5doctor.com/microdata/</link>
		<comments>http://html5doctor.com/microdata/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 15:00:14 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[microdata]]></category>
		<category><![CDATA[vocabulary]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2643</guid>
		<description><![CDATA[<p>For those who like (to argue about) semantics, <abbr>HTML</abbr>5 is fantastic. Old presentational elements now have new semantic meanings, there’s a slew of new semantic elements for us to argue about, and we've even in<code>&#60;cite&#62;</code>d a riot or two. But that's not all! Also in <abbr>HTML</abbr>5 is microdata, a new lightweight semantic meta-syntax. Using attributes, we can define nestable groups of name-value pairs of data, called microdata, which are generally based on the page’s content. It gives us a whole new way to add extra semantic information and extend <abbr>HTML</abbr>5.</p>]]></description>
			<content:encoded><![CDATA[<p>For those who like (to argue about) semantics, <abbr>HTML</abbr>5 is fantastic. <a href="http://html5doctor.com/i-b-em-strong-element/" title="The i, b, em, &amp; strong elements | HTML5 Doctor">Old presentational elements</a> now have <a href="http://html5doctor.com/small-hr-element/" title="The small &amp; hr elements | HTML5 Doctor">new semantic meanings</a>, there’s a slew of new semantic elements for us to argue about, and we've even in<code>&lt;cite&gt;</code>d a riot or two. But that's not all! Also in <abbr>HTML</abbr>5 is microdata, a new lightweight semantic meta-syntax. Using attributes, we can define nestable groups of name-value pairs of data, called <em>microdata</em>, which are generally based on the page’s content. It gives us a whole new way to <em>add extra semantic information and extend <abbr>HTML</abbr>5</em>.</p>

<nav class="in-page-nav">
<h2>In-page navigation <a class="permalink" href="#in-page-nav">#</a></h2>
<ol>
<li><a href="#syntax">Microdata syntax</a></li>
<li><a href="#microdata-action">Microdata in action</a>
<ol>
<li><a href="#schema-org-vocab">Using schema.org vocabularies</a></li>
<li><a href="#google-vocab">Using Rich Snippet vocabularies</a></li>
<li><a href="#whatwg-vocab">Using WHATWG vocabularies</a></li>
<li><a href="#browsers">Browser support</a></li>
<li><a href="#tools">Tools for making and using microdata</a></li>
<li><a href="#other-vocab">Other vocabularies</a></li>
<li><a href="#new-vocab">Making your own vocabulary</a></li></ol></li>
<li><a href="#conclusion">Conclusion</a></li>
<li><a href="#comments">Comments</a></li>
<li><a href="#changes"></a>Changes</li></ol>
</nav>

<div class="relative">
<blockquote>
<p>Sometimes, it is desirable to annotate content with specific machine-readable labels, e.g. to allow generic scripts to provide services that are customised to the page, or to enable content from a variety of cooperating authors to be processed by a single script in a consistent manner.</p>

<p>For this purpose, authors can use the microdata features described in this section. Microdata allows nested groups of name-value pairs to be added to documents, in parallel with the existing content.</p>

<footer>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html" title="5 Microdata &#8212; Web Applications 1.0"><abbr>WHATWG</abbr> <abbr>HTML</abbr> specification</a></cite></footer>
</blockquote>

<aside class="sidenote"><p>Microdata has been somewhat controversial and so is <a href="http://www.w3.org/TR/microdata/#overview" title="HTML Microdata">a separate specification at <abbr>W3C</abbr></a>, but it's still part of the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html" title="5 Microdata &#8212; Web Applications 1.0"><abbr>WHATWG</abbr> <abbr>HTML</abbr></a> specifications. <a href="http://en.wikipedia.org/wiki/File:Keep_Calm_and_Carry_On_Poster.svg" title="File:Keep Calm and Carry On Poster.svg - Wikipedia, the free encyclopedia">Keep calm and carry on</a>.</p></aside>
</div>

<p>Instead of elements, these name-value pairs are defined via attributes:</p>

<ul>
<li id="attribute-itemscope"><code>itemscope</code> — defines a group of name-value pair(s), called an <em>item</em></li>
<li id="attribute-itemprop"><code>itemprop="property-name"</code> — adds a <em>property</em> to a microdata item. The name of the property can be a word or <abbr>URL</abbr>, and the value is the ‘content’ of the element with this attribute:
<ul>
<li>For most elements, the value is the element’s text content (not including any <abbr>HTML</abbr> tags)</li>
<li>For elements with a <abbr>URL</abbr> attribute, the value is the <abbr>URL</abbr> (<code>&lt;img src=""&gt;</code>, <code>&lt;a href=""&gt;</code>, <code>&lt;object data=""&gt;</code>, etc.)</li>
<li>For the <code>&lt;time&gt;</code> element, the value is the <code>datetime=""</code> attribute</li>
<li>For <code>&lt;meta itemprop="" content=""&gt;</code>, the value is the <code>content=""</code> attribute</li>
</ul>
</li>
<li id="attribute-itemref"><code>itemref=""</code> — allows a microdata item to include <em>non-descendent properties</em> by referring to the <code>id</code>s of element(s) containing them</li>
<li id="attribute-itemtype"><code>itemtype=""</code> — defines the item’s <em>type</em> when used on the same element as <code>itemscope</code>. The <code>itemtype</code> value is a <abbr>URL</abbr> that acts as an identifying vocabulary name.</li>
<li id="attribute-itemid"><code>itemid=""</code> — allows a vocabulary to define a <em>global identifier</em> for a microdata item, for example an <abbr>ISBN</abbr> number on a book. Use <code>itemid</code> on the same element as the item’s <code>itemscope</code> and <code>itemtype</code> attributes.</li>
</ul>

<p>Let’s go through these new attributes and see how to use them in practice with everyone’s favourite example band, <a href="http://www.saltercane.com/" title="Salter Cane">Salter Cane</a>.</p>

<section id="syntax">
<h2>Microdata syntax <a class="permalink" href="#syntax">#</a></h2>

<section id="itemscope-itemprop">
<h3><code>itemscope</code> and <code>itemprop</code> <a class="permalink" href="#itemscope-itemprop">#</a></h3>

<pre><code>&lt;p itemscope&gt;I’m going to the &lt;span itemprop="name"&gt;Salter Cane&lt;/span&gt; gig next week.
Excited!&lt;/p&gt;
</code></pre>

<p>The presence of <code>itemscope</code> on the <code>&lt;p&gt;</code> element makes it into a microdata item. The attribute <code>itemprop</code> on a descendent element defines a <em>property</em> of this item (in this case, <code>name</code>) and associates it with the <em>value</em> <code>Salter Cane</code> (the <code>&lt;span&gt;</code>’s content). An item must have at least one <code>itemprop</code> to be valid.</p> <!-- todo: how are name-value pairs formatted eg via microdata.js -->

<p><code>itemprop</code> names can be words or <abbr>URL</abbr> strings. Using <abbr>URL</abbr>s makes the name <em>globally unique</em>. If you use words, it’s best to use a vocabulary and the names defined in the vocabulary, which also makes the names unique. We cover this in the section <a href="#itemtype">Typed items and globally unique names</a>.</p>

<!-- /#itemscope-itemprop --></section>

<section id="itemprop-value">
<h3><code>itemprop</code> value from an attribute <a class="permalink" href="#itemprop-value">#</a></h3>

<p>For some elements, an <code>itemprop</code>’s value comes from an attribute of the element, not the element’s text. This applies to values from attributes containing <abbr>URL</abbr>s, the <code>datetime</code> attribute, and the <code>content</code> attribute.</p>

<pre><code>&lt;p itemscope&gt;I’m going to the &lt;a itemprop="url"
  href="http://www.saltercane.com/"&gt;Salter Cane&lt;/a&gt; gig 
  &lt;time itemprop="date" datetime="2010-07-18"&gt;next week&lt;/time&gt;. Excited!&lt;/p&gt;
</code></pre>

<p>This defines an item with the properties <code>url</code> and <code>date</code> containing the values <code>http://www.saltercane.com/</code> and <code>2010-07-18</code>, respectively.</p>

<p>Note that the link’s <code>itemprop="url"</code> value is <code>http://www.saltercane.com/</code> and not the element’s “Salter Cane” text content. In microdata, the following elements contribute their <abbr>URL</abbr>s as values:</p>

<ul>
<li><code>&lt;a href=""&gt;</code></li>
<li><code>&lt;area href=""&gt;</code></li>
<li><code>&lt;audio src=""&gt;</code></li>
<li><code>&lt;embed src=""&gt;</code></li>
<li><code>&lt;iframe src=""&gt;</code></li>
<li><code>&lt;img src=""&gt;</code></li>
<li><code>&lt;link href=""&gt;</code></li>
<li><code>&lt;object data=""&gt;</code></li>
<li><code>&lt;source src=""&gt;</code></li>
<li><code>&lt;video src=""&gt;</code></li>
</ul>

<p>Similarly, the <code>&lt;time&gt;</code> element’s value is <code>2010-07-18</code> and not its text content (i.e., “next week”).</p>

<p>Conversely, the URL-containing attributes of these <abbr>HTML</abbr>5 elements are not used as property values:</p>

<ul>
<li><code>&lt;base href=""&gt;</code></li>
<li><code>&lt;script src=""&gt;</code></li>
<li><code>&lt;input src=""&gt;</code></li>
</ul>

<p>It's still possible to use the text of one of these elements as its value — e.g., <code>&lt;a href=""&gt;desired value&lt;/a&gt;</code>. We just need to add an additional <code>itemprop</code>:</p>

<pre><code>&lt;p itemscope&gt;I’m going to the &lt;a itemprop="url" href="http://www.saltercane.com/"&gt;&lt;span itemprop="name"&gt;Salter Cane&lt;/span&gt;&lt;/a&gt; gig &lt;time itemprop="date" datetime="2010-02-18"&gt;next week&lt;/time&gt;. They’re gonna rawk!&lt;/p&gt;
</code></pre>

<p>This defines an item with three properties: the <code>url</code> is <code>http://www.saltercane.com/</code>, the <code>name</code> is <code>Salter Cane</code>, and the <code>date</code> is <code>2010-07-18</code>.</p>

<p>We’ll return to the <code>&lt;meta&gt;</code> element’s <code>content</code> attribute in just a moment.</p>

<!-- /#itemprop-value --></section>

<section id="nested-items">
<h3>Nested items <a class="permalink" href="#nested-items">#</a></h3>
<p>We can make a property into a nested item by adding <code>itemscope</code> to an element with <code>itemprop</code>.</p>

<pre><code>&lt;p itemscope&gt;The &lt;span itemprop="name"&gt;Salter 
  Cane&lt;/span&gt; drummer is &lt;span itemprop="members"
  itemscope&gt;&lt;span itemprop="name"&gt;Jamie
  Freeman&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt;
</code></pre>

<p>This defines an item with two properties, <code>name</code> and <code>members</code>. The <code>name</code> is <code>Salter Cane</code>, and the <code>members</code> is a nested item, containing the property <code>name</code> with the value <code>Jamie Freeman</code>. Note that <code>members</code> doesn’t have a text value.</p>

<p>Items that aren’t part of other items (i.e., anything with <code>itemscope</code> but not <code>itemprop</code>, or the child of an element with <code>itemprop</code>) are called top-level microdata items. The microdata <abbr>API</abbr> returns top-level microdata items and their properties, which includes nested items.</p>
<!-- /#nested-items --></section>

<section id="multiple-properties">
<h3>Multiple properties <a class="permalink" href="#multiple-properties">#</a></h3>

<p>Items can have multiple properties with the same name and different values:</p>

<pre><code>&lt;span itemprop="members" itemscope&gt;The band members are
  &lt;span itemprop="name"&gt;Chris Askew&lt;/span&gt;,
  &lt;span itemprop="name"&gt;Jeremy Keith&lt;/span&gt;,
  &lt;span itemprop="name"&gt;Jessica Spengler&lt;/span&gt; and
  &lt;span itemprop="name"&gt;Jamie Freeman&lt;/span&gt;.&lt;/span&gt;
</code></pre>

<p>This defines the property <code>name</code> with four values, <code>Chris Askew</code>, <code>Jeremy Keith</code>, <code>Jessica Spengler</code> and <code>Jamie Freeman</code>.</p>

<!-- is there a short way of representing this? <code>name:Chris Askew</code>? what about properties that are themselves items? -->

<p>One element can also have multiple properties (multiple <code>itemprop=""</code> names separated by spaces) with the same value:</p>

<pre><code>&lt;p itemscope&gt;&lt;span itemprop="guitar vocals"&gt;Chris Askew&lt;/span&gt;
  is so dreamy.&lt;/p&gt;
</code></pre>

<p>This defines the properties <code>guitar</code> and <code>vocals</code>, both of which have the value <code>Chris Askew</code>.</p>
<!-- /#multiple-properties --></section>

<section id="itemref">
<h3>In-page references via <code>itemref</code> <a class="permalink" href="#itemref">#</a></h3>

<p>Items can use non-descendant properties (name-value pairs that aren’t children of the <code>itemscope</code> element) via the attribute <code>itemref=""</code>. This attribute is a list of the IDs of properties or nested items elsewhere on the page.</p>

<pre><code>&lt;p itemscope itemref="band-members"&gt;I’m going to the
  &lt;a itemprop="url" href="http://www.saltercane.com/"&gt;
  &lt;span itemprop="name"&gt;Salter Cane&lt;/span&gt;&lt;/a&gt; gig
  &lt;time itemprop="date" datetime="2010-07-18"&gt;next 
  week&lt;/time&gt;. Excited!&lt;/p&gt;
  …
  &lt;p&gt;Salter Cane are &lt;span id="band-members"
  itemprop="members" itemscope&gt;
  &lt;span itemprop="name"&gt;Chris Askew&lt;/span&gt;, 
  &lt;span itemprop="name"&gt;Jeremy Keith&lt;/span&gt;, 
  &lt;span itemprop="name"&gt;Jessica Spengler&lt;/span&gt;
  and &lt;span itemprop="name"&gt;Jamie Freeman&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt;
</code></pre>

<p>This defines the properties <code>url</code>, <code>name</code>, and <code>date</code>. Additionally, it references the ID <code>band-members</code>, which contains the item <code>members</code> with four <code>name</code> properties, each of which have a different value.</p>
<!-- /#item-ref --></section>

<section id="meta">
<h3>Using <code>&lt;meta&gt;</code> to add content via attributes <a class="permalink" href="#meta">#</a></h3>
<p>If the text you want to add isn’t already part of the page’s content, you can use the <code>content</code> attribute on the <code>&lt;meta&gt;</code> element (<code>&lt;meta itemprop="" content=""&gt;</code>) to add it.</p>

<pre><code>&lt;p itemscope&gt;&lt;span itemprop="name" itemscope&gt;Jessica Spengler
  &lt;meta itemprop="likes" content="Mameshiba"&gt;&lt;/span&gt;’s fans are always
  really raucous.&lt;/p&gt;
</code></pre>

<p>Unfortunately, some current browsers move <code>&lt;meta&gt;</code> elements into the document's <code>&lt;head&gt;</code>. The elegant workaround is to use an in-page reference via <code>itemref</code>, so it’ll be included by tools that understand microdata even if the browser has moved it.</p>

<pre><code>&lt;p itemscope&gt;&lt;span itemprop="name" itemscope itemref="meta-likes"&gt;
  Jessica Spengler&lt;meta id="meta-likes" itemprop="likes" content="Mameshiba"&gt;
  &lt;/span&gt;’s fans are always really raucous.&lt;/p&gt;
</code></pre>

<p>Both of these code snippets define the property <code>name</code> with the value <code>Jessica Spengler</code> and the nested property <code>likes</code> with the value <code><a href="http://www.youtube.com/watch?v=p-E-8RXRG1M" title="YouTube - Mameshiba 7 - Sweet Bean [with English annotations]">Mameshiba</a></code>.</p>

<aside class="sidenote"><p>Note that there’s no relationship between microdata and the page’s content. Adding all microdata via <code>&lt;meta&gt;</code> or adding metadata using only the page’s content are equivalent, and both give the same output via the microdata <abbr>API</abbr>.</p></aside>

<p>While microdata is best suited for annotating your existing content, by using <code>&lt;meta&gt;</code>-based or hidden values, microdata doesn’t have to be tied to a page’s content. In general, adding hidden content to a page is a bad idea. It’s easy to forget about and not keep up-to-date. If the information would be useful to some users, add it to the page’s content. If it’s inconvenient to add the content inside an item, consider putting it in a <code>&lt;footer&gt;</code> and including via an in-page reference.</p>

<!-- /#meta --></section>

<section id="itemtype">
<h3>Typed items (<code>itemtype</code>) and globally unique names <a class="permalink" href="#itemtype">#</a></h3>

<p>We can tie an item to a microdata vocabulary by giving it a <em>type</em>, specified via the attribute <code>itemtype=""</code> on an element with <code>itemscope</code>. The <code>itemtype=""</code> value is a <abbr>URL</abbr> representing the microdata vocabulary. Note that this <abbr>URL</abbr> is only a text string that acts as unique vocabulary identifier — it doesn’t actually need to link to an actual webpage (although it’s nice when it does). After doing this, we can use names in the vocabulary as <code>itemprop</code> names to apply vocabulary-defined semantics.</p>

<pre><code>&lt;p itemscope itemtype="http://schema.org/MusicGroup"&gt; I went to
  hear &lt;a itemprop="url" href="http://saltercane.com/"&gt;&lt;span itemprop="name"&gt;
  Salter Cane&lt;/span&gt;&lt;/a&gt; last night. They were great!&lt;/p&gt;
</code></pre>

<p>This example defines the property <code>url</code> with the value <code>http://saltercane.com/</code> and the property <code>name</code> with the value <code>Salter Cane</code> <strong>according to the <code>http://schema.org/MusicGroup</code> vocabulary</strong> (<a href="http://schema.org/MusicGroup" title="MusicGroup - schema.org"><code>MusicGroup</code> is a specialised kind of <code>Organization</code> vocabulary</a> on schema.org).</p>

<p>Alternatively, you can use <abbr>URL</abbr>s for <code>itemprop</code> names. In this case, there’s no need to use <code>itemtype</code> as the vocabulary information is already contained in the name. These are referred to as <em>globally unique names</em>. While vocabulary-based names must be used inside a typed item to have the vocabulary-defined meaning, you can use a <abbr>URL</abbr> <code>itemprop</code> name anywhere.</p>

<p>Let’s rewrite the above example using <abbr>URL</abbr>-based names:</p>

<pre><code>&lt;p itemscope&gt;I went to hear &lt;a
  itemprop="http://schema.org/MusicGroup/url"
  href="http://saltercane.com/"&gt;&lt;span
  itemprop="http://schema.org/MusicGroup/name"&gt;Salter Cane&lt;/span&gt;
  &lt;/a&gt; last night. They were great!&lt;/p&gt;
</code></pre>

<p>This allows you to use multiple vocabularies in the same code snippet, even if they use the same property names.</p>

<!-- /#itemtype --></section>

<section id="itemid">
<h3>Global identifiers with <code>itemid</code> <a class="permalink" href="#itemid">#</a></h3>

<p>Sometimes an item may be identified by a unique identifier, such as a book by its <abbr>ISBN</abbr> number. This can be done in microdata using a <em>global identifier</em> via the attribute <code>itemid=""</code>, <em>if specified by the vocabulary</em>. <code>itemid</code> can only appear on an element with both <code>itemscope</code> and <code>itemtype=""</code>, and must be a valid URL.</p>
</section>

<pre><code>&lt;p itemscope itemtype="http://vocab.example.com/book"
  itemid="urn:isbn:0321687299"&gt;
  &lt;!-- book info… --&gt;
&lt;/p&gt;
</code></pre>

<p>This defines an item containing information about a book identified by the <abbr>ISBN</abbr> number 0321687299, <em>as long as</em> the <code>http://vocab.example.com/book</code> vocabulary defines global identifiers like this.</p>

<p>This example uses a theoretical example from the spec, as schema.org Book vocabulary currently only defines <a href="http://schema.org/Book" title="Book - schema.org"><abbr>ISBN</abbr> as an <code>itemprop</code></a>, although they’ve mentioned plans to add <code>itemid</code> global identifiers to their vocabularies in the future. Global identifiers are defined for the WHATWG vocabularies for vCard and vEvent, with values like <code>UID:19950401-080045-40000F192713-0052</code> and <code>UID:19970901T130000Z-123401@host.com</code> respectively<!-- although these are invalid URLs, ref: http://www.w3.org/Bugs/Public/show_bug.cgi?id=13929 -->.</p>

<!-- /#itemid --></section>

<!-- /#syntax --></section>


<section id="microdata-action">
<h2>Microdata in action <a class="permalink" href="#microdata-action">#</a></h2>

<p>So now that we know how, <em>why</em> would we want to use microdata?</p>

<p>One use is adding extra semantics or data that we can manipulate via JavaScript in a similar way to <a href="http://html5doctor.com/html5-custom-data-attributes/" title="HTML5 Custom Data Attributes (data-*) | HTML5 Doctor">custom data attributes (<code>data-*</code>)</a>. But if we use a vocabulary via <code>itemtype</code> or <abbr>URL</abbr>-based <code>itemprop</code> names, microdata becomes considerably more powerful.</p>

<p>While microdata is <em>machine-readable without needing to know the vocabulary</em>, using a vocabulary means others can know what our properties mean. This allows the data to take on a life of its own. Say what? Well, in effect, <strong>using a vocabulary makes microdata a lightweight <abbr>API</abbr> for your content</strong>.</p>

<p>If you visited someone’s homepage, wouldn’t it be great if you could add their contact information to your address book automatically? The same is true for adding an event you’re attending to your calendar. As the syntax examples were a bit example-y, let’s see how to do that using a real-world example — an upcoming event I’m organising (well, it <em>was</em> upcoming!):</p>

<figure>
<pre><code>&lt;section&gt;
  &lt;h3&gt;&lt;a href="http://atnd.org/events/5181" title="WDE-ex Vol11『iPad
  のウェブデザイン：私たちがみつけたこと 』 : ATND"&gt;WDE-ex Vol.11 — Designing
  for iPad: Our experience so far&lt;/a&gt;&lt;/h3&gt;
  &lt;p&gt;On &lt;time datetime="2010-07-21T19:00:00+09:00"&gt;July 21st 19:00
  &lt;/time&gt;-&lt;time datetime="2010-07-21T20:00:00+09:00"&gt;20:00&lt;/time&gt;
  at &lt;a href="http://www.apple.com/jp/retail/ginza/map/"&gt;Apple Ginza&lt;/a&gt;,
  &lt;a href="http://informationarchitects.jp/" title="iA"&gt;Oliver Reichenstein,
  CEO of iA&lt;/a&gt;, will share the lessons they’ve learned while creating
  three iPad apps and one iPad website.&lt;/p&gt;
&lt;/section&gt;
</code></pre>
<blockquote><section>
  <h3><a href="http://atnd.org/events/5181" title="WDE-ex Vol11『iPad のウェブデザイン：私たちがみつけたこと 』 : ATND">WDE-ex Vol.11 — Designing for iPad: Our experience so far</a></h3>
  <p>On <time datetime="2010-07-21T19:00:00+09:00">July 21st 19:00</time>-<time datetime="2010-07-21T20:00:00+09:00">20:00</time> at <a href="http://www.apple.com/jp/retail/ginza/map/">Apple Ginza</a>, <a href="http://informationarchitects.jp/" title="iA">Oliver Reichenstein, CEO of iA</a>, will share the lessons they’ve learned while creating three iPad apps and one iPad website.</p>
</section></blockquote>
<figcaption>A Web Directions East event — in code and displayed</figcaption>
</figure>

<p>Now we could start making up our own <code>itemprop</code> names on an ad-hoc basis, but this effectively prevents anyone else from using our data. By using a vocabulary and following its rules, others can also use our data. It’s a good idea to use a vocabulary, so where do we find one?</p>

<section id="schema-org-vocab">
<h3>Using schema.org vocabularies <a class="permalink" href="#schema-org-vocab">#</a></h3>

<!-- 
* data-vocabulary rich snippet testing tool doesn’t test schema.org snippets yet (to confirm, eta about now)
* microdata and schema.org tools http://schema.rdfs.org/tools.html
	* nascent schema.org generators
		* http://schema-creator.org/ (Person, Product, Event, Organization, Movie, Book, Review)
		* http://schemafied.com/ (aggregate rating, article, contact point, creative work, event, local business, media object, nutrition information, offer, organization, person, place, postal address, product, rating, recipe, thing) includes items from other schemas
		* http://www.microdatagenerator.com/ (Attorney, Auto Dealer, Dentist, HVAC, Local Business Schema (NAP), Locksmith, Physician, Plumber, Real Estate, Restaurant Schemas)
	* Schema for WordPress plugin http://schemaforwordpress.com/
	* http://www.productontology.org for more explicit products and services to use with schema.org/Product vocab, sourced from Wikipedia
		* ref: http://groups.google.com/group/schemaorg-discussion/browse_thread/thread/0b146382537316ed# for integrating productontology schemas
	* Rich Snippets testing tool adding support for schema.org http://www.google.com/webmasters/tools/richsnippets
	* Mida, a Microdata parser/extractor library for Ruby http://lawrencewoodman.github.com/mida/
	* Translate CVS or Microdata using schema.org terms to JSON, RDF/XML or RDF/Turtle http://omnidator.appspot.com/
* controversy
	* no RDFa support
		* http://schema.rdfs.org/
	* no community input before launch
* random buildout is random
* user extensions seem pretty worthless

 -->

<p class="callout changed-block"><em><time datetime="2011-08-16T10:18:42+09:00">2011-08-16</time></em> The schema.org vocabularies have now superseded the old Google vocabularies, so I’ve updated the article to reflect this.</p>

<p>Bing, Google and Yahoo have collaborated on a set of microdata vocabularies under the name <a href="http://schema.org/" title="schema.org">schema.org</a>. By using these vocabularies we can convey semantic information in our content in a way these search engines can understand. While adding semantics using these vocabularies won’t affect your search ranking, the included data may be shown in search results. The main vocabularies schema.org offers are:</p>

<ul>
<li>Creative works: CreativeWork, Book, Movie, MusicRecording, Recipe, TVSeries…</li>
<li>Embedded non-text objects: AudioObject, ImageObject, VideoObject</li>
<li>Event</li>
<li>Organization</li>
<li>Person</li>
<li>Place, LocalBusiness, Restaurant…</li>
<li>Product, Offer, AggregateOffer</li>
<li>Review, AggregateRating</li>
</ul>

<p>They’re the cross-search engine successors to Google’s earlier <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=99170" title="Rich snippets - Webmaster Tools Help">Rich Snippets</a> vocabularies. Unlike Rich Snippets, which came in microformats and RDFa versions, schema.org vocabularies controversially <em>only</em> support microdata at the moment.</p>

<p>Taking our fairly standard <abbr>HTML</abbr>5 code for Oliver’s iPad event above, let’s add some microdata pixie dust using the schema.org vocabularies. First, the speaker (using the <a href="http://schema.org/Person" title="Person - schema.org">http://schema.org/Person vocabulary</a>) and the venue (using the <a href="http://schema.org/Organization" title="Organization - schema.org">http://schema.org/Organization vocabulary</a>):</p>

<figure>
<pre><code>&lt;section&gt;
  &lt;h3&gt;&lt;a href="http://atnd.org/events/5181" title="WDE-ex Vol11『iPad
  のウェブデザイン：私たちがみつけたこと 』 : ATND"&gt;WDE-ex Vol.11 — Designing
  for iPad: Our experience so far&lt;/a&gt;&lt;/h3&gt;
  &lt;p&gt;On &lt;time datetime="2010-07-21T19:00:00+09:00"&gt;July 21st 19:00
  &lt;/time&gt;-&lt;time datetime="2010-07-21T20:00:00+09:00"&gt;20:00&lt;/time&gt; at
  &lt;span <mark>itemscope itemtype="http://schema.org/Organization"</mark>&gt;
  &lt;a <mark>itemprop="url"</mark> href="http://www.apple.com/jp/retail/ginza/map/"&gt;
  &lt;span <mark>itemprop="name"</mark>&gt;Apple Ginza&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;,
  &lt;span <mark>itemscope itemtype="http://schema.org/Person"</mark>&gt;
  &lt;a <mark>itemprop="url"</mark> href="http://informationarchitects.jp/" title="iA"&gt;
  &lt;span <mark>itemprop="name"</mark>&gt;Oliver Reichenstein&lt;/span&gt;, CEO of iA&lt;/a&gt;
  &lt;/span&gt;, will share the lessons they’ve learned while creating three
  iPad apps and one iPad website.&lt;/p&gt;
&lt;/section&gt;
</code></pre>
<figcaption>Adding schema.org microdata attributes for the speaker and location (ref: <a href="http://html5doctor.com/demos/microdata/example1.html" title="Microdata example 1: schema.org Person and Organization vocabularies">standalone file</a>). Because they’re attributes, there is no change in how the <abbr>HTML</abbr> is displayed</figcaption>
</figure>

<p>While this content will still look the same, adding these microdata items means the following information is now machine readable:</p>

<ul>
<li>A company’s name (<code>name</code>)</li>
<li>That company’s <abbr>URL</abbr> (<code>url</code> on <code>&lt;a&gt;</code>)</li>
<li>A person’s name (<code>name</code>)</li>
<li>A <abbr>URL</abbr> associated with that person (<code>url</code> on <code>&lt;a&gt;</code>)</li>
</ul>

<p>In JSON (ref: <a href="http://foolip.org/microdatajs/live/?html=%3Csection%3E%0A%20%20%3Ch3%3E%3Ca%20href%3D%22http%3A%2F%2Fatnd.org%2Fevents%2F5181%22%20title%3D%22WDE-ex%20Vol11%E3%80%8EiPad%0A%20%20%E3%81%AE%E3%82%A6%E3%82%A7%E3%83%96%E3%83%87%E3%82%B6%E3%82%A4%E3%83%B3%EF%BC%9A%E7%A7%81%E3%81%9F%E3%81%A1%E3%81%8C%E3%81%BF%E3%81%A4%E3%81%91%E3%81%9F%E3%81%93%E3%81%A8%20%E3%80%8F%20%3A%20ATND%22%3EWDE-ex%20Vol.11%20%E2%80%94%20Designing%0A%20%20for%20iPad%3A%20Our%20experience%20so%20far%3C%2Fa%3E%3C%2Fh3%3E%0A%20%20%3Cp%3EOn%20%3Ctime%20datetime%3D%222010-07-21T19%3A00%3A00%2B09%3A00%22%3EJuly%2021st%2019%3A00%0A%20%20%3C%2Ftime%3E-%3Ctime%20datetime%3D%222010-07-21T20%3A00%3A00%2B09%3A00%22%3E20%3A00%3C%2Ftime%3E%20at%0A%20%20%3Cspan%20itemscope%20itemtype%3D%22http%3A%2F%2Fschema.org%2FOrganization%22%3E%0A%20%20%3Ca%20itemprop%3D%22url%22%20href%3D%22http%3A%2F%2Fwww.apple.com%2Fjp%2Fretail%2Fginza%2Fmap%2F%22%3E%0A%20%20%3Cspan%20itemprop%3D%22name%22%3EApple%20Ginza%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fspan%3E%2C%0A%20%20%3Cspan%20itemscope%20itemtype%3D%22http%3A%2F%2Fschema.org%2FPerson%22%3E%0A%20%20%3Ca%20itemprop%3D%22url%22%20href%3D%22http%3A%2F%2Finformationarchitects.jp%2F%22%20title%3D%22iA%22%3E%0A%20%20%3Cspan%20itemprop%3D%22name%22%3EOliver%20Reichenstein%3C%2Fspan%3E%2C%20CEO%20of%20iA%3C%2Fa%3E%0A%20%20%3C%2Fspan%3E%2C%20will%20share%20the%20lessons%20they%E2%80%99ve%20learned%20while%20creating%20three%0A%20%20iPad%20apps%20and%20one%20iPad%20website.%3C%2Fp%3E%0A%3C%2Fsection%3E">Live Microdata</a>) this would be:</p>

<pre><code>{
  "items": [
    {
      "type": "http://schema.org/Organization",
      "properties": {
        "url": [
          "http://www.apple.com/jp/retail/ginza/map/"
        ],
        "name": [
          "Apple Ginza"
        ]
      }
    },
    {
      "type": "http://schema.org/Person",
      "properties": {
        "url": [
          "http://informationarchitects.jp/"
        ],
        "name": [
          "Oliver Reichenstein"
        ]
      }
    }
  ]
}
</code></pre>

<p>So we now have a semantic association between a company and a <abbr>URL</abbr> and between a person and a <abbr>URL</abbr>. With the right tool, we could add this information to an address book automatically.</p>

<p>Next, let’s add microdata attributes to the event data, using the <a href="http://schema.org/Event" title="Event - schema.org">http://schema.org/Event vocabulary</a>:</p>

<figure>
<pre><code>&lt;section <mark>itemscope itemtype="http://schema.org/Event"</mark>&gt;
  &lt;h3&gt;&lt;a <mark>itemprop="url"</mark> href="http://atnd.org/events/5181" title="WDE-ex
  Vol11『iPad のウェブデザイン：私たちがみつけたこと 』 : ATND"&gt;&lt;span
  <mark>itemprop="summary"</mark>&gt;WDE-ex Vol.11 — Designing for iPad: Our experience so
  far&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
  &lt;p <mark>itemprop="description"</mark>&gt;On &lt;time <mark>itemprop="startDate"</mark>
  datetime="2010-07-21T19:00:00+09:00"&gt;July 21st 19:00&lt;/time&gt;-
  &lt;time <mark>itemprop="endDate"</mark> datetime="2010-07-21T20:00:00+09:00"&gt;20:00
  &lt;/time&gt; at &lt;span <mark>itemprop="location"</mark> itemscope
  itemtype="http://schema.org/Organization"&gt;&lt;a itemprop="url"
  href="http://www.apple.com/jp/retail/ginza/map/"&gt;&lt;span itemprop="name"&gt;
  Apple Ginza&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span itemscope
  itemtype="http://schema.org/Person"&gt;&lt;a itemprop="url"
  href="http://informationarchitects.jp/" title="iA"&gt;&lt;span itemprop="name"&gt;
  Oliver Reichenstein&lt;/span&gt;, CEO of iA&lt;/a&gt;&lt;/span&gt;, will share
  the lessons they’ve learned while creating three iPad apps and
  one iPad website.&lt;/p&gt;
&lt;/section&gt;
</code></pre>
<blockquote><section itemscope itemtype="http://schema.org/Event">
<h3><a itemprop="url" href="http://atnd.org/events/5181" title="WDE-ex Vol11『iPad のウェブデザイン：私たちがみつけたこと 』 : ATND"><span itemprop="summary">WDE-ex Vol.11 — Designing for iPad: Our experience so far</span></a></h3>
<p itemprop="description">On <time itemprop="startDate" datetime="2010-07-21T19:00:00+09:00">July 21st 19:00</time>-<time itemprop="endDate" datetime="2010-07-21T20:00:00+09:00">20:00</time> at <span itemprop="location" itemscope itemtype="http://schema.org/Organization"><a itemprop="url" href="http://www.apple.com/jp/retail/ginza/map/"><span itemprop="name">Apple Ginza</span></a></span>, <span itemscope itemtype="http://schema.org/Person"><a itemprop="url" href="http://informationarchitects.jp/" title="iA"><span itemprop="name"> Oliver Reichenstein</span>, CEO of iA</a></span>, will share the lessons they’ve learned while creating three iPad apps and one iPad website.</p>
</section></blockquote>
<figcaption>A code sample with microdata describing an event (ref: <a href="http://html5doctor.com/demos/microdata/example2.html" title="Microdata example 2: schema.org Event, Person and Organization vocabularies">standalone file</a>). Adding the microdata attributes doesn’t change how the HTML is displayed.</figcaption>
</figure>

<aside class="sidenote"><p>While these <code>itemprop</code>s will probably be self-explanatory, you can see descriptions of what each <code>itemprop</code> means on the <a href="http://schema.org/Organization" title="Organization - schema.org">Organization</a>, <a href="http://schema.org/Person" title="Person - schema.org">Person</a>, and <a href="http://schema.org/Event" title="Event - schema.org">Event vocabulary</a> pages.</p></aside>

<p>Now things are a lot more interesting! We can extract the following data:</p>

<ul>
<li>Event details
<ul><li>Event name (<code>summary</code>)</li>
<li>Event start and end time (<code>startDate</code> and <code>endDate</code>)</li>
<li>Event summary (<code>summary</code>)</li>
<li>Event <abbr>URL</abbr> (<code>url</code> on <code>&lt;a&gt;</code>)</li>
<li>Event location (<code>location</code>), which is represented by:
<ul>
<li>Company name (<code>name</code>)</li>
<li>Company <abbr>URL</abbr> (<code>url</code> on <code>&lt;a&gt;</code>)</li>
</ul>
</li>
</ul></li>
<li>Speaker details (well, someone connected with the event, although this connection isn’t explicit)
<ul><li>A person’s name (<code>name</code>)</li>
<li>That person’s associated <abbr>URL</abbr> (<code>url</code>)</li></ul>
</li>
</ul>

<p>Google provides a <a href="http://www.google.com/webmasters/tools/richsnippets" title="Webmaster Tools - Rich Snippets Testing Tool">Rich Snippet testing tool</a>, which shows what data it can extract from the schema.org microdata:</p>

<aside class="sidenote"><p>This tool was originally developed for <a href="#google-vocab">Rich Snippets</a>, so it’ll also work for those vocabularies for microdata, microformats and RDFa</p></aside>

<img src="http://html5doctor.com/wp-content/uploads/2011/08/rich-snippet-data2.png" alt="Data extracted from schema.org microdata by the Rich Snippet testing tool" title="Rich Snippet Data" width="495" height="341" class="alignnone size-full wp-image-3628" />

<p>Google could use this additional data in search results as follows:</p>

<img src="http://html5doctor.com/wp-content/uploads/2010/10/rich-snippet.png" alt="Google Rich Snippet testing tool preview, showing data we marked up using microdata" width="507" height="180" class="alignnone size-full wp-image-2659" />

<p>The summary (linked to the event <abbr>URL</abbr>) and the date and venue are included. Nice! Just by using a vocabulary, Google (or a script supporting microdata) can discover lots of useful data about our event without needing one of those pesky natural language interpreters (otherwise known as humans).</p>

<p>Anyone who has used microformats before will also notice these vocabularies look very similar to hCard and hCalendar, although there are a couple of name changes — e.g., hCalendar’s <code>class="dtstart"</code> becomes <code>itemprop="startDate"</code>.</p>

<p>While the schema.org vocabularies are all the search engines are promising to support, you can <a href="http://schema.org/docs/extension.html" title="schema.org - Extending Schemas">extend these vocabularies</a> yourself. The safest ways to do this would be via:</p>

<ul>
<li>the <a href="http://www.productontology.org" title="The Product Types Ontology: Use Wikipedia pages for describing products or services with GoodRelations and schema.org">Product Types Ontology</a> for products or services, based on Wikipedia</li>
<li>the <a href="http://www.heppnetz.de/projects/goodrelations/" title="GoodRelations: The Professional Web Vocabulary for E-Commerce">GoodRelations vocabulary terms</a> for e-commerce, which is <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=186036" title="Product properties: GoodRelations and hProduct - Webmaster Tools Help">supported (along with hProduct) by Rich Snippets</a></li>
<li>making your own schema.org vocabulary extension collaboratively using the <a href="http://groups.google.com/group/schemaorg-discussion" title="Schema.org Discussion | Google Groups">schema.org email list</a> (although read <a href="#new-vocab">Making your own vocabulary</a> later in this article first)</li>
</ul>

<!-- /#schema-org-vocab --></section>

<section id="google-vocab">
<h3>Using Google’s Rich Snippets vocabularies <a class="permalink" href="#google-vocab">#</a></h3>

<p>Google also has some basic vocabularies (precursors of schema.org vocabularies) for the following kinds of data, under the moniker of <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=99170" title="Rich snippets - Webmaster Tools Help">Rich Snippets</a>:</p>

<ul>
<li>people</li>
<li>businesses and organizations</li>
<li>events</li>
<li>products</li>
<li>reviews</li>
<li>recipes</li>
</ul>

<p>These vocabularies support microformats and <abbr>RDFa</abbr>, two other ways to add extra semantics to our content, in addition to microdata. Apart from this difference, they’re basically identical to the matching schema.org vocabularies, except they use <a href="http://www.data-vocabulary.org/" title="Data-Vocabulary.org | Official Website">www.data-vocabulary.org</a> instead of schema.org in the <code>itemtype</code>. While Google still supports them, the newer schema.org offers more vocabularies that are also supported by Bing and Yahoo, so choose schema.org vocabularies as long as you’re happy with microdata. You might still want to check out the <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=99170" title="Rich snippets - Webmaster Tools Help">Rich Snippets documentation</a>, as it includes code samples and is generally better than schema.org’s at the time of writing.</p>

<!-- /#google-vocab --></section>

<section id="whatwg-vocab">
<h3>Using <abbr>WHATWG</abbr>/microformats.org vocabularies <a class="permalink" href="#whatwg-vocab">#</a></h3>

<p>If you’re familiar with microformats or want more properties than Google’s vocabularies, the <abbr>WHATWG</abbr> <abbr>HTML</abbr>5 specification actually contains microdata vocabularies for both the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#vcard" title="4.12 Links &mdash; HTML5 (including next generation additions still in development)">vCard</a> and <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#vevent" title="4.12 Links &mdash; HTML5 (including next generation additions still in development)">vEvent<!-- todo: iCalendar? check --></a> specifications that hCard and hCalendar are based on, plus <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#licensing-works" title="4.12 Links &mdash; HTML5 (including next generation additions still in development)">a licensing vocabulary</a>.</p>

<p>Let’s take our earlier example and rewrite it using these vocabularies instead:</p>

<figure>
<pre><code>&lt;section itemscope
  itemtype="http://microformats.org/profile/hcalendar#vevent"&gt;
  &lt;h3&gt;&lt;a itemprop="url" href="http://atnd.org/events/5181" title="WDE-ex
  Vol11『iPad のウェブデザイン：私たちがみつけたこと 』 : ATND"&gt;&lt;span
  itemprop="summary"&gt;WDE-ex Vol.11 — Designing for iPad: Our experience so
  far&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
  &lt;p itemprop="description"&gt;On &lt;time itemprop="dtstart"
  datetime="2010-07-21T19:00:00+09:00"&gt;July 21st 19:00&lt;/time&gt;-
  &lt;time itemprop="dtend" datetime="2010-07-21T20:00:00+09:00"&gt;20:00&lt;/time&gt;
  at &lt;span itemprop="location" itemscope
  itemtype="http://microformats.org/profile/hcard"&gt;&lt;a itemprop="url"
  href="http://www.apple.com/jp/retail/ginza/map/"&gt;&lt;span itemprop="fn org"&gt;
  Apple Ginza&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span itemscope
  itemtype="http://microformats.org/profile/hcard"&gt;&lt;a itemprop="url"
  href="http://informationarchitects.jp/" title="iA"&gt;&lt;span itemprop="fn"&gt;
  Oliver Reichenstein&lt;/span&gt;, CEO of iA&lt;/a&gt;&lt;/span&gt;, will share
  the lessons they’ve learned while creating three iPad apps and one
  iPad website.&lt;/p&gt;
&lt;/section&gt;
</code></pre>
<figcaption>An HTML code sample with microdata describing an event, using vCard- and vEvent-based vocabularies (ref: <a href="http://html5doctor.com/demos/microdata/example3.html" title="Microdata example 3: WHATWG/microformats.org vEvent and vCard vocabularies">standalone file</a>)</figcaption>
</figure>

<p>Currently, search engines don’t map these vocabularies to schema.org ones. It’s possible they will at some stage, so decide which vocabularies to use based on what information you want to mark up, as the data is accessible regardless.</p>

<section id="uf-wiki">
<h4>Criticism on microformats.org <a class="permalink" href="#uf-wiki">#</a></h4>

<p>Despite these vocabularies being based on vCard and vEvent and using microformats.org as their <abbr>URL</abbr>s, the microformats wiki actually warns against using the vCard and vEvent microdata vocabularies, stating:</p>

<blockquote><p>For common semantics on the web … microformats are still simpler and easier than microdata, and are already well implemented across numerous services and tools.</p>
<footer><cite><a href="http://microformats.org/wiki/microdata#summary" title="microdata · Microformats Wiki">Microdata — Microformats wiki</a></cite></footer>
</blockquote>

<p>Personally, I think the difference is marginal. If you use the recommended microformat <code>profile</code> links, I’d say it’s a wash. (But of course no one does ;). Microdata is actually simpler to use for date/time data than the microformat equivalents (although it is less permissive for <a href="http://html5doctor.com/the-time-element/" title="The time element (and microformats) | HTML5 Doctor">fuzzy or ancient antiquity times</a>), and it's more explicit, for example, avoiding the internationalisation issues of the “implied <code>fn</code> optimisation”. Tool support is a valid concern, but again I expect this to change over time — microdata is relatively new after all.</p>

<!-- /#uf-wiki --></section>
<!-- /#whatwg-vocab --></section>

<section id="browsers">
<h3>Browser support <a class="permalink" href="#browsers">#</a></h3>

<p>The microdata specification describes the <a href="http://www.w3.org/TR/microdata/#using-the-microdata-dom-api" title="HTML Microdata">microdata <abbr>DOM</abbr> <abbr>API</abbr></a>, which allows us to access top-level items and their properties. <del datetime="2011-08-16T11:03:53+0900">Unfortunately, no browser supports this yet.</del> <ins datetime="2011-08-16T11:16:22+0900"><a href="http://my.opera.com/desktopteam/blog/2011/07/27/latency-microdata-qresync" title="Opera Desktop Team - Network latency improvements, Microdata and QRESYNC">Opera has experimental support in their latest snapshot</a>, with support expected in Opera 12.</ins> It’s also <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=591467">being implemented by Mozilla</a>.</p>

<table>
	<caption>Browser support for microdata <i>(as of <time datetime="2011-08-16">16th August, 2011</time>)</i></caption>
<thead>
	<tr><th scope="col">Browser</th><th scope="col">Support</th></tr>
</thead>
<tbody>
	<tr><th scope="row">Chrome</th><td>No</td></tr>
	<tr><th scope="row">Safari</th><td>No</td></tr>
	<tr><th scope="row">Firefox</th><td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=591467">Work in progress</a></td></tr>
	<tr><th scope="row">Opera</th><td><a href="http://my.opera.com/desktopteam/blog/2011/07/27/latency-microdata-qresync" title="Opera Desktop Team - Network latency improvements, Microdata and QRESYNC">In snapshot 12.00-1033</a></td></tr>
	<tr><th scope="row">Internet Explorer</th><td>No</td></tr>
</tbody>
</table>

<p>But that’s okay because this data is still useful for search engine robots and third party tools. For example, Bing, Google, and Yahoo are using microdata with the schema.org vocabularies in search results.</p>

<!-- /#browsers --></section>

<section id="tools">
<h3>Tools for making and using microdata <a class="permalink" href="#tools">#</a></h3>

<p>With the right tools, we could use this data complete with its explicit semantics to, for example, add a microdata-annotated event directly into a calendar — very handy if you were planning to attend. With the release of schema.org, <a href="http://schema.rdfs.org/tools.html" title="schema.rdfs.org - Tools">tools for microdata are starting to appear</a>, but are still somewhat thin on the ground. (No Firefox plugin?! Inconceivable!). However we have libraries for three languages now:</p>

<ul>
<li><a href="http://foolip.org/microdatajs/live/" title="Live Microdata">Live Microdata</a> and the associated <a href="http://gitorious.net/microdatajs/microdatajs" title="microdatajs in HTML5 Microdata JavaScript - Gitorious">microdatajs</a> by <a href="http://twitter.com/foolip" title="@foolip on Twitter">Philip Jägenstedt</a></li>
<li><ins datetime="2011-07-14T06:25:19+0900">the <a href="http://soyrex.com/php-microdata/" title="PHP Microdata Parser - Library to parse microdata from HTML">PHP Microdata Parser</a> by <a href="https://twitter.com/soyrex">Alex Holt</a></ins></li>
<li><ins datetime="2011-08-16T11:22:17+0900"><a href="http://lawrencewoodman.github.com/mida/" title="Mida - A Microdata extractor/parser library for Ruby">Mida</a>, a Microdata parser/extractor library for Ruby and command line tool by <a href="http://techtinkering.com/" title="TechTinkering">Lawrence Woodman</a></ins></li>
</ul>

<p>Live Microdata converts microdata into <abbr>JSON</abbr>. If you’re using <abbr>WHATWG</abbr>/microformats.org vocabularies for vCard or vEvent, it also produces vCard and iCal output. <ins datetime="2011-07-14T06:31:07+0900">The PHP Microdata library allows you to parse microdata in an HTML file, returning JSON or a PHP array.</ins> <ins datetime="2011-08-16T11:30:16+0900">Mida allows you to extract microdata as JSON, and search for or inspect items. It supports defining vocabularies, and includes schema.org vocabularies. You can even use it from the command line.</ins></p>

<p>Until there is native <abbr>API</abbr> support in browsers, we can use these libraries to access microdata. For example, you could put microdatajs on your own server to provide vCard and iCal file downloads, to allow adding the data to an address book or calendar app.</p>

<p><a href="http://validator.nu/">Validator.nu</a> will validate your use of microdata, but not whether it conforms to a vocabulary. Google’s <a href="http://www.google.com/webmasters/tools/richsnippets" title="Webmaster Tools - Rich Snippets Testing Tool">Rich Snippets testing tool</a> also validates microdata. In addition, if you’re using the schema.org or Rich Snippets vocabularies it <em>should</em> display how that data could be incorporated into search results, as we saw in the <a href="#schema-org-vocab">Using schema.org vocabularies</a> examples above. At the time of writing it isn’t, possibly due to this tool being updated for schema.org vocabularies.</p>

<p>If you have valid microdata in these vocabularies search engines <em>will</em> understand that data, but currently you have to <a href="http://www.google.com/support/webmasters/bin/request.py?contact_type=rich_snippets_feedback" title="Interested in Rich Snippets? - Webmaster Tools Help">“register your interest” in having your rich snippets actually be displayed</a> (<a href="http://knol.google.com/k/google-rich-snippets-tips-and-tricks#Frequently_Asked_Questions" title="Google Rich Snippets Tips and Tricks - Google Rich Snippetsさんのコレクション">more information</a>).</p>

<p>If you’d like a simple way to create microdata, with schema.org there are now several web-based form options:</p>

<ul>
<li><a href="http://schema-creator.org/" title="Schema Creator">Schema Creator</a> supports the schema.org vocabularies for Person, Product, Event, Organization, Movie, Book, and Review</li>
<li><a href="http://schemafied.com/" title="schemafied">Schemafied</a> supports the schema.org vocabularies for aggregate rating, article, contact point, creative work, event, local business, media object, nutrition information, offer, organization, person, place, postal address, product, rating, recipe, and thing, and also includes relevant items from other schemas</li>
<li><a href="http://www.microdatagenerator.com/" title="Schema.org Generator For Local SEO | Rich Snippets &amp; Microdata Generator">Microdata Generator</a> supports the schema.org vocabularies for Attorney, Auto Dealer, Dentist, HVAC, Local Business Schema (NAP), Locksmith, Physician, Plumber, Real Estate, and Restaurant</li>
<li><a href="http://microdata.freebaseapps.com/">HTML5 Microdata Templates</a> supports the WHATWG and Rich Snippets vocabularies for events, organisations, people, reviews, and content</li>
</ul>

<p>For <abbr>CMS</abbr>s, there’s a <a href="http://schemaforwordpress.com/" title="Schema for WordPress &#124; Home">Schema for WordPress plugin</a>, and initial work on adding microdata to Drupal too.</p>

<!-- /#tools --></section>

<section id="other-vocab">
<h3>Other vocabularies <a class="permalink" href="#other-vocab">#</a></h3>

<p>Here's a short list of microdata vocabularies and their <code>itemtype</code>s:</p>

<dl>
<dt>Person</dt>
<dd><ul>
<li><a href="http://schema.org/Person">schema.org Person</a> — <code>http://schema.org/Person</code></li>
<li><a href="http://microformats.org/profile/hcard" title="hCard 1.0.1 XMDP profile">vCard</a> — <code>http://microformats.org/profile/hcard</code></li>
<li><a href="http://data-vocabulary.org/Person" title="Data-Vocabulary.org | Person microdata description">Rich Snippets Person</a> — <code>http://data-vocabulary.org/Person</code></li>
</ul></dd>
<dt>Organisation or business</dt>
<dd><ul>
<li><a href="http://schema.org/Organization">schema.org Organization</a> — <code>http://schema.org/Organization</code></li>
<li><a href="http://microformats.org/profile/hcard" title="hCard 1.0.1 XMDP profile">vCard</a> (using <code>fn org</code>) — <code>http://microformats.org/profile/hcard</code></li>
<li><a href="http://data-vocabulary.org/Organization" title="Data-Vocabulary.org | Organization microdata description">Rich Snippets Organization</a> — <code>http://data-vocabulary.org/Organization</code></li>
</ul></dd>
<dt>Calendar</dt>
<dd><ul>
<li><a href="http://schema.org/Event">schema.org Event</a> — <code>http://schema.org/Event</code></li>
<li><a href="http://microformats.org/profile/hcalendar#vevent" title="hCalendar 1.0.1 XMDP profile">vEvent</a> — <code>http://microformats.org/profile/hcalendar#vevent</code></li>
<li><a href="http://data-vocabulary.org/Event" title="Data-Vocabulary.org | Event microdata description">Rich Snippets Event</a> — <code>http://data-vocabulary.org/Event</code></li>
</ul></dd>
<dt>Review</dt>
<dd><ul>
<li><a href="http://schema.org/Review">schema.org Review</a> — <code>http://schema.org/Review</code></li>
<li><a href="http://www.schema.org/AggregateRating">schema.org AggregateRating</a> — <code>http://www.schema.org/<mark>AggregateRating</mark></code> (different to Rich Snippets <code>itemtype</code>)</li>
<li><a href="http://microformats.org/wiki/hreview" title="hReview 0.3 &middot; Microformats Wiki">hReview</a> — <code>http://microformats.org/wiki/hreview</code></li>
<li><a href="http://data-vocabulary.org/Review" title="Data-Vocabulary.org | Review microdata description">Rich Snippets Review</a> — <code>http://data-vocabulary.org/Review</code></li>
<li><a href="http://www.data-vocabulary.org/Review-aggregate/" title="Data-Vocabulary.org | Review microdata description">Rich Snippets Review-aggregate</a> — <code>http://www.data-vocabulary.org/Review-aggregate</code></li>
</ul></dd>
<dt>License</dt>
<dd><ul><li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#licensing-works" title="4.12 Links &mdash; HTML5 (including next generation additions still in development)">Licensing works</a> — <code>http://n.whatwg.org/work</code></li></ul></dd>
<dt>Products and services</dt>
<dd><ul>
<li><a href="http://schema.org/Product">schema.org Product</a> — <code>http://schema.org/Product</code>
<ul><li>This can be extended with <a href="http://www.productontology.org" title="The Product Types Ontology: Use Wikipedia pages for describing products or services with GoodRelations and schema.org">productontology.org descriptions</a> (<a href="http://www.productontology.org/#microdata">example</a>)</li></ul>
</li>
<li><a href="http://microformats.org/wiki/hproduct" title="hProduct &middot; Microformats Wiki">hProduct</a> — <code>http://microformats.org/wiki/hproduct</code></li>
<li><a href="http://purl.org/goodrelations/">GoodRelations Product</a> — <code>http://purl.org/goodrelations/</code> (e.g. <code>&lt;a itemprop="http://purl.org/goodrelations/v1#availableDeliveryMethods"      href="hhttp://purl.org/goodrelations/v1#UPS"&gt;via UPS&lt;/a&gt;</code>)</li>
<li><a href="http://data-vocabulary.org/Product" title="Data-Vocabulary.org | Product microdata description">Rich Snippets Product</a> — <code>http://data-vocabulary.org/Product</code></li>
</ul></dd>
<dt>Atom feed</dt>
<dd><ul>
<li><a href="http://microformats.org/wiki/hatom" title="hAtom 0.1 &middot; Microformats Wiki">hAtom</a> — <code>http://microformats.org/wiki/hatom</code></li>
</ul></dd>
<dt>Recipes</dt>
<dd><ul>
<li><a href="http://schema.org/Recipe" title="Recipe - schema.org">schema.org Recipe</a> — <code>http://schema.org/Recipe</code></li>
<li><a href="http://microformats.org/wiki/hrecipe" title="hRecipe 0.22 &middot; Microformats Wiki">hRecipe</a> — <code>http://microformats.org/wiki/hrecipe</code></li>
<li><a href="http://data-vocabulary.org/Recipe" title="Data-Vocabulary.org | Recipe microdata description">Rich Snippets Recipe</a> — <code>http://data-vocabulary.org/Recipe</code></li>
</ul></dd>
</dl>

<p>It’s also possible to use <abbr>RDFa</abbr> vocabularies by <strong>both</strong> specifying the <code>itemtype</code> and using URLs for <code>itemprop</code> names. Refer to <a href="http://schema.rdfs.org/" title="schema.rdfs.org - Home">schema.rdfs.org</a> for Linked Data versions of schema.org vocabularies, and the <abbr>RDF</abbr> vocabulary clearing-house (“namespace lookup”) <a href="http://prefix.cc/">http://prefix.cc</a>.</p>

<!-- /#other-vocab --></section>

<section id="new-vocab">
<h3>Making your own vocabulary <a class="permalink" href="#new-vocab">#</a></h3>

<p>If you don’t see a suitable vocabulary, you could make your own. The microdata vocabularies in the <abbr>HTML</abbr>5 spec are included as examples of how to do it. Basically:</p>

<ol>
<li><strong>Work out your vocabulary’s rules.</strong> This is a little like setting up a database — work out names for each type of data, then think what kind of data each name’s value should/must contain (<abbr>URL</abbr>, datetime, free text, text with restrictions…), and whether something needs to be the child of something else.</li>
<li><strong>Make up a <abbr>URL</abbr></strong> on a domain you control, and ideally put your vocabulary specification there.</li>
<li><strong>Use the URL in <code>itemtype=""</code></strong> to reference your vocabulary.</li>
</ol>

<p>There are, however, very good reasons <em>not</em> to make your own vocabulary. They can be quite hard to create, as evidenced by the work that goes into <a href="http://microformats.org/wiki/process" title="process &middot; Microformats Wiki">microformats vocabularies</a>. For truly site-specific data, you’re fine with <a href="http://html5doctor.com/html5-custom-data-attributes/" title="HTML5 Custom Data Attributes (data-*) | HTML5 Doctor">HTML5 custom <code>data-*</code> attributes</a>, or using microdata the same way. But to really get the quasi-<abbr>API</abbr> benefits of microdata, you need to use a vocabulary that’s on more than just your site. To make a vocabulary like that, you need to cover not just your own needs, but 80% of the needs of everyone else in the same subject area.</p>

<p>First, check out <a href="http://microformats.org/wiki" title="Microformats">microformats.org</a> to see if there’s anything in roughly the same area you can just microdata-ify. After that, try <abbr>RDFa</abbr> vocabularies. If you still have no luck, try collaborating on a vocabulary with other people in your subject domain. If you’re going to write your own microdata vocabulary from scratch, I’d recommend <a href="http://microformats.org/wiki/process" title="process &middot; Microformats Wiki">trying to write a microformat first</a>, as you’ll get a lot of good feedback and they have good info on how to write one. It’s easy to then convert the resulting microformat vocabulary into a microdata vocabulary.</p>

<!-- /#new-vocab --></section>

<!-- /#microdata-action --></section>

<section id="conclusion">
<h2>Conclusion <a class="permalink" href="#conclusion">#</a></h2>

<p>We’ve gone through the building blocks of microdata: a simple five-attribute combo of <code>itemscope</code>, <code>itemprop=""</code>, <code>itemref=""</code>, <code>itemtype=""</code>, and <code>itemid=""</code> on most any element, plus using <code>content</code> on <code>&lt;meta&gt;</code>. We’ve looked at how to combine these attributes to add complex semantic annotations and relationships to your content. We’ve also looked at using common vocabularies, or even creating a vocabulary, to allow the annotated data to be reused widely. This makes creating a meta-<abbr>API</abbr> for your website easy enough that <em>even a designer</em> could do it! ;-)</p>

<p>But microdata is not the only way to extend the semantics of <abbr>HTML</abbr>5 and add extra meaning. We’ve already looked at <a href="http://html5doctor.com/microformats/" title="Extending HTML5 — Microformats | HTML5 Doctor">Microformats</a>, and RDFa is up next.</p>

<section id="further-reading">
<h3>Further reading and related links <a class="permalink" href="#further-reading">#</a></h3>
<ul>
<li>Dive into HTML5 — <a href="http://diveinto.html5doctor.com/extensibility.html" title="Distributed Extensibility - Dive Into HTML 5">“Distributed,” “Extensibility,” &amp; Other Fancy Words</a>, by Mark Pilgrim</li>
<li><a href="http://blog.foolip.org/2009/08/23/microformats-vs-rdfa-vs-microdata/" title="Microformats vs RDFa vs Microdata &laquo; Philip Jägenstedt">Microformats vs RDFa vs Microdata</a> by Philip Jägenstedt</li>
<li><a href="http://www.google.com/support/webmasters/bin/topic.py?topic=21997" title="Rich snippets and structured markup - Webmaster Tools Help">Google Help — Rich Snippets</a>; contains a great introduction to microdata, microformats and <abbr>RDFa</abbr>, with code samples in each language</li>
<li><a href="http://knol.google.com/k/google-rich-snippets-tips-and-tricks#" title="Google Rich Snippets Tips and Tricks">Knol — Rich Snippets Tips and Tricks</a> has more information on Google’s Rich Snippets</li>
</ul>
<!-- /#further-reading --></section>

<p><small>My thanks to <a href="http://saltercane.com/" title="Salter Cane">Salter Cane</a> for agreeing to be microdata-ified. Much obliged! Their new album <a href="http://saltercane.com/sorrow/" title="Salter Cane: Sorrow">Sorrow</a> is worth checking out… ;-)</small></p>
<!-- /#conclusion --></section>

<section id="changes" class="changes">
<h2>Changes <a class="permalink" href="#changes">#</a></h2>

<ol class="semantic-list">
<li><time datetime="2011-07-14">2011-07-14</time> Added PHP Microdata Parser to the <a href="#tools">tools section</a></li>
<li><time datetime="2011-08-16">2011-08-16</time> Updating article for <a href="#schema-org-vocab">schema.org vocabularies</a> which are also supported by Bing and Yahoo, and supersede the <a href="#google-vocab">Google-only Rich Snippets</a> ones. Also updating <a href="#browsers">browser support</a> (Opera) and <a href="#tools">tools</a> (Mida) sections</li>
<li><time datetime="2011-08-29T10:38:31+09:00">2011-08-29</time> Finished <a href="#schema-org-vocab">schema.org updates</a>, added valicator.nu to the <a href="#tools">tools section</a>, and rewrote <a href="#itemid"><code>itemid</code> section</a> for clarity, since <a href="http://www.brucelawson.co.uk/2011/microdata-help-please/" title="Bruce Lawson&#8217;s  personal site&nbsp;: microdata help, please">Dr Bruce was having a spot of bother</a> with it</li>
</ol>
<!-- /#changes --></section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/time-and-data-element/" rel="bookmark" class="crp_title">Goodbye time, datetime, and pubdate. Hello data and value.</a></li><li><a href="http://html5doctor.com/html5-seo-search-engine-optimisation/" rel="bookmark" class="crp_title">HTML5 and Search Engine Optimisation (SEO)</a></li><li><a href="http://html5doctor.com/microformats/" rel="bookmark" class="crp_title">Extending HTML5 — Microformats</a></li><li><a href="http://html5doctor.com/the-address-element/" rel="bookmark" class="crp_title">The Address Element</a></li><li><a href="http://html5doctor.com/blockquote-q-cite/" rel="bookmark" class="crp_title">Quoting and citing with <code>&lt;blockquote&gt;</code>, <code>&lt;q&gt;</code>, <code>&lt;cite&gt;</code>, and the cite attribute</a></li></ul></div><p><a href="http://html5doctor.com/microdata/" rel="bookmark">Extending HTML5 — Microdata</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on November 23, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/microdata/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>HTML5 Simplequiz #4: figures, captions and alt text</title>
		<link>http://html5doctor.com/html5-simplequiz-4-figures-captions-and-alt-text/</link>
		<comments>http://html5doctor.com/html5-simplequiz-4-figures-captions-and-alt-text/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 14:15:49 +0000</pubDate>
		<dc:creator>Bruce Lawson</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Simplequiz]]></category>
		<category><![CDATA[Structure]]></category>
		<category><![CDATA[WAI-ARIA]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2694</guid>
		<description><![CDATA[Simplequiz #4 asks about alt text on images that are captioned using HTML5 figure and figcaption. Steve Faulkner moderates this week.]]></description>
			<content:encoded><![CDATA[<p>A few years ago, <a href="http://www.simplebits.com/">Dan Cederholm</a> published a series of articles called <a href="http://simplebits.com/categories/simplequiz/">Simplequiz</a>. Dan posed some options for marking up a specified piece of content and invited readers to choose the one they felt was the best way to mark that up. The value was in the comments, where people defended their choices and debated the options (which means it is <em>the law</em> that you read the preceding comments before adding your own).</p>
<p>With Dan&#8217;s blessing, we&#8217;re running an occasional series of <abbr>HTML</abbr>5 Simplequizzes.</p>
<p><abbr>HTML</abbr>5 offers a way to associate a figure (which can be an image, a video, a graph, a table, a pull-quote) with a caption using the <a href="http://dev.w3.org/html5/spec/grouping-content.html#the-figure-element"><code>&lt;figure&gt;</code> element</a>. This is very common in print, but there has been no way to do this in <abbr>HTML</abbr>4, as there is no element that groups a figure and a caption (other than a semantically-empty <code>&lt;div&gt;</code>).</p>
<p>Our question this week is about alternate text for images that are captioned. I&#8217;ve gotten this wrong before (in print, embarrassingly), as have two highly-clueful friends of mine. The man who set us right will be your moderator and quizmaster this week, <a href="http://twitter.com/stevefaulkner">Steve Faulkner</a> of <a href="http://www.paciellogroup.com/">The Paciello Group</a>, possibly the most respected accessibility agency out there.</p>
<p>We have an image as a figure in a story simply about a dignitary opening a new branch of Mr Lidl&#8217;s marvelous emporium. The caption will be &#8220;Mayor of Casterbridge opens a new Lidl supermarket&#8221;.</p>
<p><img src="http://www.html5doctor.com/wp-content/uploads/2010/11/figure.jpg" alt="Generic picture of man cutting ribbon"></p>
<p>What&#8217;s the best markup for this? Show your working out.</p>
<h2>A:</h2>
<pre><code> &lt;figure&gt;
 &lt;img src=blah.png
  alt=&quot;A portly gent cuts a ribbon. He is with five small children, and is watched by two middle-aged woman, a very tall smiling man, and a small crowd&quot;&gt;
  &lt;figcaption&gt;
  Mayor of Casterbridge opens a new Lidl supermarket.
  &lt;/figcaption&gt;
 &lt;/figure&gt;</code></pre>
<h2>B:</h2>
<pre><code>&lt;figure role=img aria-labelledby=lidl&gt;
&lt;img src=blah.png alt=&quot;&quot;&gt;
 &lt;figcaption id=lidl&gt;
  Mayor of Casterbridge opens a new Lidl supermarket.
 &lt;/figcaption&gt;
&lt;/figure&gt;</code></pre>
<h2>C:</h2>
<pre><code>&lt;figure&gt;
&lt;img src=blah.png&gt;
 &lt;figcaption&gt;
 Mayor of Casterbridge opens a new Lidl supermarket.
 &lt;/figcaption&gt;
&lt;/figure&gt;</code></pre>
<h2>D:</h2>
<pre><code>&lt;figure&gt;
&lt;img src=blah.png alt=&quot;&quot;&gt;
 &lt;figcaption&gt;
 &lt;p&gt;Mayor of Casterbridge opens a new Lidl supermarket.&lt;/p&gt;
 &lt;/figcaption&gt;
&lt;/figure&gt;</code></pre>
<h2>E:</h2>
<pre><code>&lt;figure&gt;
&lt;img src=blah.png alt=&quot;Mayor of Casterbridge opens a new Lidl supermarket.&quot;&gt;
 &lt;figcaption&gt;
  Mayor of Casterbridge opens a new Lidl supermarket.
&lt;/figcaption&gt;
&lt;/figure&gt;</code></pre>
<p>Steve will wrap up the quiz next Thursday.</p>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/html5-simplequiz-6-zeldmans-fat-footer/" rel="bookmark" class="crp_title">HTML5 Simplequiz 6: Zeldman&#8217;s fat footer</a></li>
<li><a href="http://html5doctor.com/html5-simplequiz-2-citing-people/" rel="bookmark" class="crp_title">HTML5 Simplequiz #2: citing people</a></li>
<li><a href="http://html5doctor.com/html5-simplequiz-1/" rel="bookmark" class="crp_title">HTML5 Simplequiz #1</a></li>
<li><a href="http://html5doctor.com/the-figure-figcaption-elements/" rel="bookmark" class="crp_title">The figure &#038; figcaption elements</a></li>
<li><a href="http://html5doctor.com/html5-simplequiz-5-urls-of-commenters/" rel="bookmark" class="crp_title">HTML5 Simplequiz 5: URLs of commenters</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/html5-simplequiz-4-figures-captions-and-alt-text/" rel="bookmark">HTML5 Simplequiz #4: figures, captions and alt text</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on November 5, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/html5-simplequiz-4-figures-captions-and-alt-text/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
		<item>
		<title>HTML5 Simplequiz #3: how to mute a video</title>
		<link>http://html5doctor.com/html5-simplequiz-3-how-to-mute-a-video/</link>
		<comments>http://html5doctor.com/html5-simplequiz-3-how-to-mute-a-video/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 08:35:16 +0000</pubDate>
		<dc:creator>Bruce Lawson</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[JavaScript APIs]]></category>
		<category><![CDATA[multimedia]]></category>
		<category><![CDATA[Simplequiz]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[muted]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2628</guid>
		<description><![CDATA[This is a bit of a special Simplequiz this week. Simon Pieters, who works on multimedia QA for Opera and is one of those working on the HTML5 spec, asked us to run a quiz that would help the spec writers decide on a new aspect of the language. ]]></description>
			<content:encoded><![CDATA[<p>This is a bit of a special Simplequiz this week. Simon Pieters (<a href="http://twitter.com/zcorpan">@zcorpan</a>), who works on multimedia QA for Opera and is one of those working on the HTML5 spec, asked us to run a quiz that would help the spec writers decide on a new aspect of the language. What power you wield, gentle reader! Over to Simon&hellip;</p>
<p>This SimpleQuiz is a bit different to previous SimpleQuizzes, since we&#8217;d like to use the result of this quiz to inform a design decision in the HTML5 spec. The question concerns how to mute a video in markup, and how this should be reflected in the DOM.</p>
<p>The use case is wanting to have multiple videos playing at once, but with all but one being muted at a time. This can be done today by setting <code>.muted = true</code> with script, but it would be more convenient to be able to mute with markup.</p>
<p>The <code>.muted</code> IDL attribute reflects the user setting of muted for the video element &#8212; if the user clicks &#8220;mute&#8221; in the native video controls, then the value of <code>.muted</code> changes, and vice versa. It would make sense for the browser to remember the mute setting for individual video elements on page reload (or later visit), so that the user doesn&#8217;t have to re-mute them.</p>
<p>This is where it starts to get hairy if we introduce a content attribute for muting. (Note that code fragments below aren&#8217;t real code, just suggestions.)</p>
<p>We could introduce <code>muted=""</code> which is reflected by <code>.muted</code> (i.e. if one changes, so does the other), but this would cause the DOM to mutate during parsing if the remembered setting doesn&#8217;t match the markup, i.e. you would get <code>muted=""</code> to appear in the DOM if the video is muted by the user even though there was no such attribute in the markup, which could confuse your scripts or style sheets if it&#8217;s not what you expected to happen.</p>
<p>We could introduce <code>defaultmuted=""</code> which is reflected by <code>.defaultMuted</code>, and just let the user setting change <code>.muted</code>, but <code>defaultmuted=""</code> is a bit long and ugly in markup.</p>
<p>We could have <code>muted=""</code> which is reflected by <code>.defaultMuted</code> and let the user setting change <code>.muted</code>, but it might be confusing for some people. On the other hand it is consistent with <code>&lt;input value&gt;</code> and <code>.defaultValue</code>.</p>
<p>What do you think? Which is the best option? Is there another option that is better than any of the above?
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/html5-audio-the-state-of-play/" rel="bookmark" class="crp_title">HTML5 Audio — The State of Play</a></li>
<li><a href="http://html5doctor.com/html5-simplequiz-4-figures-captions-and-alt-text/" rel="bookmark" class="crp_title">HTML5 Simplequiz #4: figures, captions and alt text</a></li>
<li><a href="http://html5doctor.com/the-nsfw-element/" rel="bookmark" class="crp_title">The nsfw element</a></li>
<li><a href="http://html5doctor.com/the-video-element/" rel="bookmark" class="crp_title">The video element</a></li>
<li><a href="http://html5doctor.com/html5-simplequiz-2-citing-people/" rel="bookmark" class="crp_title">HTML5 Simplequiz #2: citing people</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/html5-simplequiz-3-how-to-mute-a-video/" rel="bookmark">HTML5 Simplequiz #3: how to mute a video</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 15, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/html5-simplequiz-3-how-to-mute-a-video/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Extending HTML5 — Microformats</title>
		<link>http://html5doctor.com/microformats/</link>
		<comments>http://html5doctor.com/microformats/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 13:30:18 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[microformats]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2304</guid>
		<description><![CDATA[<p>HTML5 contains a bunch of new semantic goodness, but sometimes we need more semantics than what’s available. This is the first article in a series looking at various ways to extend HTML5 — first up, microformats.</p>]]></description>
			<content:encoded><![CDATA[<p>While <abbr>HTML</abbr>5 has a bunch of semantic elements, including new ones like <a href="http://html5doctor.com/the-article-element/" title="The article element | HTML5 Doctor"><code>&lt;article&gt;</code></a> and <a href="http://html5doctor.com/nav-element/" title="Semantic navigation with the nav element | HTML5 Doctor"><code>&lt;nav&gt;</code></a>, sometimes there just isn’t an element with the right meaning. What we want are ways to extend what we’ve got, to add <em>extra semantics</em> that are <em>machine-readable</em> — data that a browser, script, or robot can use.</p>

<nav>
<h2>In-page navigation</h2>
<ol>
<li><a href="#native-ways">Native ways to extend <abbr>HTML</abbr></a></li>
<li><a href="#introducing">Introducing microformats</a>
	<ol>
		<li><a href="#uf-specs">Microformat specifications</a>
		<ol>
			<li><a href="#uf-published">Published microformats</a></li>
			<li><a href="#uf-draft">Draft microformats</a></li>
			<li><a href="#uf-patterns">Microformat patterns</a></li>
		</ol>
		</li>
	</ol>
</li>
<li><a href="#lightning">A lightning introduction to using microformats</a>
	<ol>
		<li><a href="#rel-license">Using rel-license for licensing information</a></li>
		<li><a href="#xfn">Using XHTML Friends Network (<abbr>XFN</abbr>)</a></li>
		<li><a href="#hcard">Using hCard for contact information</a>
			<ol><li><a href="#hcard-org">Organisations, addresses, and phone numbers</a></li></ol>
		</li>
		<li><a href="#hcalendar">Using hCalendar for event information</a></li>
	</ol>
</li>
<li><a href="#uf-in-html5">Using microformats in <abbr>HTML</abbr>5</a>
	<ol>
		<li><a href="#votelinks">The <code>rev</code>-based VoteLinks microformat</a></li>
		<li><a href="#profile">The <code>profile</code> attribute</a></li>
		<li><a href="#uf-wiki">Microformats specifications vs <abbr>HTML</abbr>5</a></li>
		<li><a href="#uf-tools">Microformats-consuming tools (or, the problem with <abbr>HTML</abbr> Tidy)</a>
			<ol><li><a href="#uf-tools-table">Microformats Tool support</a></li></ol>
		</li>
	</ol>
</li>
<li><a href="#conclusion">Conclusion</a>
	<ol><li><a href="#ref">Reference books and DVDs</a></li></ol>
</li>
<li><a href="#changes">Changes</a></li>
</ol>
</nav>

<section id="native-ways">
<h2>Native ways to extend <abbr>HTML</abbr></h2>

<p>There were five fundamental ways we could extend <abbr>HTML</abbr> 4:</p>

<ul>
<li><code>&lt;meta&gt;</code> element</li>
<li><code>class</code> attribute</li>
<li><code>rel</code> attribute</li>
<li><code>rev</code> attribute</li>
<li><code>profile</code> attribute</li>
</ul>

<p>In <abbr>HTML</abbr>5, <code>rev</code> has fallen by the wayside, becoming obsolete since hardly anyone used it correctly, and because it can be replaced by <code>rel</code>. <code>profile</code> is also obsolete, and there is no support for namespaces in <abbr>HTML</abbr>5. However, <code>&lt;meta&gt;</code>, <code>class</code>, and <code>rel</code> <em>are</em> all in <abbr>HTML</abbr>5. In fact, <code>&lt;meta&gt;</code> now has <a href="http://dev.w3.org/html5/spec-author-view/semantics.html#standard-metadata-names" title="4 The elements of HTML &mdash; HTML5 (Edition for Web Authors)">spec-defined <code>name</code>s</a> and a way to <a href="http://wiki.whatwg.org/wiki/MetaExtensions" title="MetaExtensions - WHATWG Wiki">submit new <code>name</code> values</a>, and <code>rel</code> has <a href="http://dev.w3.org/html5/spec-author-view/links.html#linkTypes" title="4.12 Links — HTML5 (Edition for Web Authors)">several new link types</a> defined in the <abbr>HTML</abbr>5 specification and <a href="http://wiki.whatwg.org/wiki/RelExtensions" title="RelExtensions - WHATWG Wiki">a way to submit more</a> too.</p>

<p>Even better, <a href="http://dev.w3.org/html5/spec-author-view/content-models.html#annotations-for-assistive-technology-products-aria" title="3.2.5 Content models — HTML5 (Edition for Web Authors)"><abbr>WAI</abbr>-<abbr>ARIA</abbr>’s <code>role</code> and <code>aria-*</code> attributes are allowed in <abbr>HTML</abbr>5</a>, and <abbr>HTML</abbr>5 validators can check <abbr>HTML</abbr>5+<abbr>ARIA</abbr>. Other new methods of extending <abbr>HTML</abbr>5 include <a href="http://html5doctor.com/html5-custom-data-attributes/" title="HTML5 Custom Data Attributes (data-*) | HTML5 Doctor">custom data attributes (<code>data-*</code>)</a>, <a href="http://html5doctor.com/microdata/" title="Extending HTML5 — Microdata | HTML5 Doctor">microdata</a>, and <abbr>RDFa</abbr>.</p>

<p>Finally there are <strong>microformats</strong>. As Dr. Bruce touched on microformats in his article on <a href="http://html5doctor.com/the-time-element/" title="The time element (and microformats) | HTML5 Doctor">the <code>&lt;time&gt;</code> element</a>, let’s delve a little deeper into what microformats are and how to use them in HTML5.</p>
</section><!-- /#native-ways -->

<section id="introducing">
<h2>Introducing microformats</h2>

<p><a href="http://microformats.org/wiki/Main_Page" title="Welcome to the microformats wiki! &middot; Microformats Wiki">Microformats</a> are a collection of vocabularies for extending <abbr>HTML</abbr> with additional <em>machine-readable</em> semantics. They are designed for humans first and machines second. This is currently accomplished via agreed-upon <code>class</code>, <code>rel</code>, <code>rev</code> and <code>profile</code> attributes, coding patterns, and nesting.</p>

<p>Being machine readable means a robot or script that understands the microformat vocabulary being used can understand and process the marked-up data. Each microformat defines a specific type of data and is usually based on existing data formats — like <b>vcard</b> (address book data; <a href="http://www.ietf.org/rfc/rfc2426.txt" title="vCard MIME Directory Profile">RFC2426</a>) and <b>icalendar</b> (calendar data; <a href="http://www.ietf.org/rfc/rfc2445.txt" title="Internet Calendaring and Scheduling Core Object Specification (iCalendar)">RFC 2445</a>) — or common coding patterns (‘paving the cowpaths’ of the web).</p>

<p>Despite their humble beginnings, microformats have also been a runaway success, and they're <a href="http://microformats.org/2010/07/08/microformats-org-at-5-hcards-rich-snippets" title="Microformats | weblog | microformats.org at 5: Two Billion Pages With hCards, 94% of Rich Snippets">far more widely deployed</a> than other “big S” <a href="http://en.wikipedia.org/wiki/Semantic_Web" title="Semantic Web - Wikipedia, the free encyclopedia">Semantic web</a> technologies. For example, many services, such as Twitter and Flickr, offer profile information in hCard format by default, so you may already have a microformatted profile even if you’ve never used microformats before.</p>

<section id="uf-specs">
<h3>Microformat specifications</h3>

<p>There are currently 34 microformats specifications (listed below) in varying levels of completion, and you can find out more about them on the <a href="http://microformats.org/wiki/Main_Page" title="Welcome to the microformats wiki! &middot; Microformats Wiki">microformats wiki</a>.</p>

<section id="uf-published">
<h4>Published microformats</h4>

<ul>
<li>Elemental (simple) microformats
<ul>
<li><abbr title="XHTML Friends Network">XFN</abbr> — specify relationships with people<!--(人間関係を表現する)--></li>
<li><abbr title="XHTML Meta Data Profiles">XMDP</abbr> — add metadata profiles<!--(メタデータのプロフィール)--></li>
<li>VoteLinks — indicate agreement or disagreement with, or indifference to, the link’s destination<!--(投票のリンク)--></li>
<li>rel-nofollow — don’t give ‘weight’ to a link (don’t give ‘Google juice’; mainly for search engines)<!--(リンクにランキングの指標として用いないように)--></li>
<li>rel-license — specify license information<!--(コンテンツのライセンス情報)--></li>
<li>rel-tag — add tags<!--(キーワードやテーマのタグ)--></li>
</ul>
</li>
<li>Compound microformats
<ul>
<li>hCard — contact information for people and organisations<!--(人や会社、組織や場所情報)--></li>
<li>hCalendar — time-based information, such as events<!--(カレンダー・イベント情報)--></li>
<li><abbr title="Extensible Open XHTML Outlines">XOXO</abbr> — outlines <!--(アウトラインフォーマット)--></li>
</ul>
</li>
</ul>
</section><!-- /#uf-published -->

<section id="uf-draft">
<h4>Draft microformats</h4>

<ul class="columns">
<li>adr</li>
<li>geo</li>
<li>hAtom</li>
<li>hAudio</li>
<li>hListing</li>
<li>hMedia</li>
<li>hNews</li>
<li>hProduct</li>
<li>hRecipe</li>
<li>hResume</li>
<li>hReview</li>
<li>rel-directory</li>
<li>rel-enclosure</li>
<li>rel-home</li>
<li>rel-payment</li>
<li>robots exclusion</li>
<li><ins datetime="2010-08-18T21:42:52+09:00">Species</ins></li>
<li>xFolk</li>
</ul>

<p>Despite being drafts, many of these are in widespread use.</p>
</section><!-- /#uf-draft -->

<section id="uf-patterns">
<h4>Microformat patterns</h4>

<p>These common coding patterns are just best practices that are frequently used in writing plain old semantic <abbr>HTML</abbr> (POSH) to create microformats.</p>

<ul class="column">
<li><code>&lt;abbr&gt;</code> design pattern</li>
<li><code>class</code> design pattern</li>
<li>date design pattern</li>
<li>datetime design pattern</li>
<li>include pattern</li>
<li>value <code>class</code> pattern</li>
<li><code>rel</code> design pattern</li>
</ul>
</section><!-- /#uf-patterns -->

<p>These specifications and patterns cover many common types of data. They’ve been created by a grass-roots organisation of interested people, and anyone is welcome to contribute or even propose a new microformat.</p>
</section><!-- /#uf-specs -->
</section><!-- /#introducing -->

<section id="lightning">
<h2>A lightning introduction to using microformats</h2>

<p>For those of you that haven't used microformats before, I’ll briefly introduce some simple microformats — hopefully so simple you’ll be encouraged to use them right away!</p>

<section id="rel-license">
<h3>Using rel-license for licensing information</h3>

<p>Adding license information is quite a common activity, and while we can add a link to Creative Commons or another license easily enough, someone would have to read it to understand the content’s license:</p>

<pre><code>&lt;small&gt;This article is licensed under a 
  &lt;a href=&quot;http://creativecommons.org/licenses/by-nc-sa/2.0/&quot;&gt;
  Creative Commons Attribution Non-commercial Share-alike 
  (By-&lt;abbr&gt;NC&lt;/abbr&gt;-&lt;abbr&gt;SA&lt;/abbr&gt;) license&lt;/a&gt;.
&lt;/small&gt;</code></pre>

<p>If this information was machine-readable, search engines could use it to help consumers searching by license. By using the <code>rel-license</code> microformat to add <code>rel="license"</code> to the license link (indicating it’s the license for the page’s main content), we can do just that:</p>

<figure>
<pre><code>&lt;small&gt;This article is licensed under a 
  &lt;a <mark>rel=&quot;license&quot;</mark> href=&quot;http://creativecommons.org/licenses/by-nc-sa/2.0/&quot;&gt;
  Creative Commons Attribution Non-commercial Share-alike 
  (By-&lt;abbr&gt;NC&lt;/abbr&gt;-&lt;abbr&gt;SA&lt;/abbr&gt;) license&lt;/a&gt;.
&lt;/small&gt;</code></pre>
<blockquote><p><small>This article is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution Non-commercial Share-alike (By-<abbr>NC</abbr>-<abbr>SA</abbr>) license</a>.</small></p></blockquote>
<figcaption>A rel-license-formatted code sample with an example rendering</figcaption>
</figure>

<p>This may be so easy you don’t even realise you’ve just microformatted the link! In fact, Google already uses this data to allow us to search by license (look in <a href="http://www.google.com/advanced_search" title="Google Advanced Search">advanced search</a>, in the extra options).</p>

<img src="http://html5doctor.com/wp-content/uploads/2010/07/google-license-search.png" alt="Google advanced search options, showing the “Usage rights” pulldown" width="540" height="227" />
</section><!-- /#rel-license -->

<section id="xfn">
<h3>Using XHTML Friends Network (<abbr>XFN</abbr>)</h3>

<p>Maybe we should term this one eXtensible Friends Network instead :-) <abbr>XFN</abbr> is a way of specifying your relationship with people — everything from “met” to “sweetheart” — using the <code>rel</code> attribute on a link to their homepage.</p>

<p>There are two main values: <code>rel="contact"</code> for someone you know how to get in touch with, and <code>rel="me"</code>. The <code>rel="me"</code> value allows you to claim ownership of your various websites, including your accounts on social networks. For example, I could have a profile with a link to my Twitter account:</p>

<pre><code>&lt;p&gt;Oli Studholme &mdash; &lt;a href=&quot;http://twitter.com/boblet&quot;&gt;follow me on
  Twitter (@boblet)&lt;/a&gt;&lt;/p&gt;</code></pre>

<p>A person can infer that @boblet is my Twitter username, but by adding <code>rel="me"</code> we can state this relationship in a machine-readable way.</p>

<pre><code>&lt;p&gt;Oli Studholme &mdash; &lt;a <mark>rel=&quot;me&quot;</mark> href=&quot;http://twitter.com/boblet&quot;&gt;follow me on
  Twitter (@boblet)&lt;/a&gt;&lt;/p&gt;</code></pre>

<p>In order to actually work, this would need to be on my personal homepage, with the same homepage added to my Twitter profile. By doing this, a social web app that understands <abbr>XFN</abbr> could confirm @boblet is me, check my friends on Twitter, check if those people are already registered, and then allow me to follow them all with one click — much easier.</p>

<p>For more on this idea, check out <a href="http://gmpg.org/xfn/and/#idconsolidation" title="XFN: Services &amp; Technologies">Identity consolidation and the <abbr>XFN</abbr> <code>rel="me"</code> value</a>, <a href="http://microformats.org/wiki/RelMeAuth" title="RelMeAuth &middot; Microformats Wiki">the RelMeAuth proposal</a> on the microformats wiki, and <a href="http://code.google.com/apis/socialgraph/docs/" title="About the Social Graph - Social Graph API - Google Code">Google’s Social Graph <abbr>API</abbr></a>. It seems <a href="http://tantek.com/2010/191/t1/facebook-distributed-social-web-diso-rel-me-representative-hcard-microformats">Facebook is supporting <code>rel="me"</code></a> too.</p>
</section><!-- /#xfn -->

<p>Rel-license and <abbr>XFN</abbr> are simple <code>rel</code>-based microformats, but even with their simplicity you can see the potential power in this machine-readable stuff. Now let’s look at microformats for contact and event information.</p>

<section id="hcard">
<h3>Using hCard for contact information</h3>

<p>Almost every website has an about page with some contact information:</p>

<pre><code>&lt;p&gt;Oli Studholme &mdash; &lt;a href=&quot;http://oli.jp/&quot;&gt;http://oli.jp&lt;/a&gt;, or 
&lt;a href=&quot;http://twitter.com/boblet&quot;&gt;follow me on Twitter (@boblet)&lt;/a&gt;.&lt;/p&gt;</code></pre>

<p>Unfortunately, adding someone’s contact information to your phone or address book generally involves a lot of copying and pasting. If the data was machine-readable, however, we could use a tool to do that. Let’s add the <a href="http://microformats.org/wiki/hcard" title="hCard 1.0 · Microformats Wiki">hCard</a> microformat to this code snippet.</p>

<figure>
<pre><code>&lt;p <mark>class=&quot;vcard&quot;</mark>&gt;&lt;span <mark>class=&quot;fn&quot;</mark>&gt;Oli Studholme&lt;/span&gt; &mdash; 
&lt;a <mark>class=&quot;url&quot;</mark> href=&quot;http://oli.jp/&quot;&gt;http://oli.jp&lt;/a&gt;, or 
&lt;a <mark>class=&quot;url&quot;</mark> href=&quot;http://twitter.com/boblet&quot;&gt;follow me on Twitter 
(@&lt;span <mark>class=&quot;nickname&quot;</mark>&gt;boblet&lt;/span&gt;)&lt;/a&gt;.&lt;/p&gt;</code></pre>
<blockquote><p class="vcard"><span class="fn">Oli Studholme</span> — <a class="url" href="http://oli.jp/">http://oli.jp</a>, or <a class="url" href="http://twitter.com/boblet">follow me on Twitter (@<span class="nickname">boblet</span>)</a>.</p></blockquote>
<figcaption>An hCard-formatted code sample with an example rendering</figcaption>
</figure>

<p>So we’ve added a bunch of classes. There’s nothing special about that, of course, until you realise they're all part of the hCard microformat. The first one is <code>vcard</code> on the containing <code>&lt;p&gt;</code> element, indicating that there's hCard data here. Then we have <code>fn</code>, which stands for full name, <code>url</code> for an associated homepage, and <code>nickname</code> for, well, a nickname.</p>

<p>This is a simple example, and in fact a valid hCard (generally) only requires <code>vcard</code> and <code>fn</code>. But hCard has much more depth. We can mark up all kinds of contact-related data: addresses, company information, even a profile photo. For example, we can explicitly specify a given name and family name (this is required for Chinese, Korean, Japanese and Vietnamese names), even middle names and titles.</p>

<pre><code>&lt;span <mark>class=&quot;vcard&quot;</mark>&gt;&lt;span <mark>class=&quot;fn n&quot;</mark> lang=&quot;ja&quot;&gt;&lt;span <mark>class=&quot;family-name&quot;</mark>&gt;
スタッドホルム&lt;/span&gt;・&lt;span <mark>class=&quot;given-name&quot;</mark>&gt;オリ&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</code></pre>

<p>The additional <code>n</code> value is actually required, but can be inferred (the so-called “<a href="http://microformats.org/wiki/hcard#Implied_.22n.22_Optimization" title="hCard 1.0 &middot; Microformats Wiki">implied <code>n</code> optimisation</a>”) and therefore omitted for names that follow these patterns:</p>
<ul>
<li>given-name family-name</li>
<li>family-name, given-name</li>
</ul>

<p>So what’s the benefit of this? Well, there are several tools that will convert this hCard-microformatted data into a vcard file we can download and automatically add to our address book. Nifty!</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2010/07/operator-hcard.png" alt="The Firefox Operator plugin’s hCard export options" width="370" height="125">
<figcaption>The <a href="https://addons.mozilla.org/firefox/addon/4106">Firefox plugin Operator</a> can save hCard-formatted content as a vcard, or add it to Yahoo Contacts</figcaption>
</figure>

<p>It’s also recognised by <a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&amp;answer=99170">Google’s Rich Snippets</a> and <a href="http://developer.yahoo.com/searchmonkey/" title="SearchMonkey - YDN">Yahoo’s SearchMonkey</a>, useful for the contact information on any company website.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2010/07/google-rich-snippet.png" alt="A preview of how rich snippet data may be incorporated into Google’s search results—in this example “Osaka” and “designer”" width="494" height="175">
<img src="http://html5doctor.com/wp-content/uploads/2010/07/google-rich-snippet-data.png" alt="Microformat hCard data extracted by the Google Rich Snippet testing tool" width="290" height="248">
<figcaption>Google’s Rich Snippet testing tool for an hCard (Note the “Osaka - designer” in the search preview)</figcaption>
</figure>

<section id="hcard-org">
<h4>Organisations, addresses, and phone numbers</h4>

<p>Smaller company websites often have the company name and contact details in the footer, so let’s briefly see how to do that.</p>

<figure>
<pre><code>&lt;p class="vcard"&gt;
&lt;a class="fn org url" href="http://www.w3.org/Consortium/contact-keio" title="Contact Information for W3C/Keio"&gt;&lt;span class="organization-name"&gt;W3C&lt;/span&gt;/&lt;span class="organization-unit"&gt;Keio&lt;/span&gt;&lt;/a&gt;&lt;br&gt;
&lt;span class="adr"&gt;&lt;a class="extended-address" href="http://www.keio.ac.jp/english/about_keio/campus_info/sfc1.html"&gt;Keio University Shonan Fujisawa Campus&lt;/a&gt;&lt;br&gt;
&lt;span class="street-address"&gt;5322 Endo&lt;/span&gt;, &lt;span class="locality"&gt;Fujisawa city&lt;/span&gt;,&lt;br&gt;
&lt;span class="region"&gt;Kanagawa prefecture&lt;/span&gt; &lt;span class="postal-code"&gt;252-8520&lt;/span&gt; &lt;b class="country"&gt;Japan&lt;/b&gt;&lt;br&gt;
&lt;span class="tel"&gt;Telephone: &lt;span class="value"&gt;+81-466-49-1170&lt;/span&gt;&lt;/span&gt;&lt;br&gt;
&lt;span class="tel"&gt;&lt;span class="type"&gt;Fax&lt;/span&gt;: &lt;span class="value"&gt;+81-466-49-1171&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
</code></pre>
<p class="vcard">
<a class="fn org url" href="http://www.w3.org/Consortium/contact-keio" title="Contact Information for W3C/Keio"><span class="organization-name">W3C</span>/<span class="organization-unit">Keio</span></a><br />
<span class="adr"><a class="extended-address" href="http://www.keio.ac.jp/english/about_keio/campus_info/sfc1.html">Keio University Shonan Fujisawa Campus</a><br />
<span class="street-address">5322 Endo</span>, <span class="locality">Fujisawa city</span>,<br />
<span class="region">Kanagawa prefecture</span> <span class="postal-code">252-8520</span> <b class="country">Japan</b><br />
<span class="tel">Telephone: <span class="value">+81-466-49-1170</span></span><br />
<span class="tel"><span class="type">Fax</span>: <span class="value">+81-466-49-1171</span></span></span>
</p>
<figcaption>A microformatted example company hCard, complete with address, and a sample rendering</figcaption>
</figure>

<p>By using <code>fn</code> together with <code>org</code> we can create an hCard for an organisation. Each part of the address is specified (<code>&lt;span&gt;</code>licious!), and we’ve also included a phone number (<code>tel</code>’s default type is voice) and fax number (specifying <code>type</code> and using the value class pattern).</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2010/08/google-rich-snippet2.png" alt="A preview of how rich snippet data may be incorporated into Google’s search results—in this example “Kanagawa Prefecture” and “W3C”" width="475" height="165">
<img src="http://html5doctor.com/wp-content/uploads/2010/08/google-rich-snippet-data2.png" alt="Microformat hCard data extracted by the Google Rich Snippet testing tool" width="415" height="283">
<figcaption>Google’s Rich Snippet testing tool for an organisation hCard (note the address and organisation info in the search preview)</figcaption>
</figure>

<p>And with Operator, we can add this hCard to our computer’s address book in one click. If you’ve ever manually added an address to your address book, you’ll love this ;-)</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2010/08/operator-hcard-export.png" alt="Exporting an hCard to your computer’s address book via Operator" width="139" height="85">
<img src="http://html5doctor.com/wp-content/uploads/2010/08/address-book.png" alt="An hCard exported by Operator is automatically added to the address book" width="599" height="340">
<figcaption>Adding hCard-formatted contact information to your address book with one click</figcaption>
</figure>
</section><!-- /#hcard-org -->

</section><!-- /#hcard -->

<section id="hcalendar">
<h3>Using hCalendar for event information</h3>

<p>Let’s briefly look at marking up a simple event. Here’s one I’m involved with:</p>

<pre><code>&lt;h3&gt;&lt;a href=&quot;http://atnd.org/events/5181&quot;&gt;WDE-ex Vol.11 &mdash;
  Designing for iPad: Our experience so far&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;July 21st 19:00-20:00 at 
&lt;a href=&quot;http://www.apple.com/jp/retail/ginza/map/&quot;&gt;Apple Ginza&lt;/a&gt;.&lt;/p&gt;</code></pre>

<p>Just by reading, we understand the event name, date, time, and location. But this information is difficult for computers to extract. By using the hCard microformat, it will be machine-readable.</p>

<figure>
<pre><code>&lt;div <mark>class=&quot;vevent&quot;</mark>&gt;
  &lt;h3&gt;&lt;a <mark>class=&quot;url summary&quot;</mark> href=&quot;http://atnd.org/events/5181&quot;&gt;
  WDE-ex Vol.11 &mdash; Designing for iPad: Our experience so far&lt;/a&gt;&lt;/h3&gt;
  &lt;p&gt;&lt;span <mark>class=&quot;dtstart&quot;</mark>&gt;&lt;abbr <mark>class=&quot;value&quot;</mark> title=&quot;2010-07-21&quot;&gt;
  July 21st&lt;/abbr&gt; &lt;span <mark>class=&quot;value&quot;</mark>&gt;19:00&lt;/span&gt;&lt;/span&gt;-
  &lt;span <mark>class=&quot;dtend&quot;</mark>&gt;&lt;span <mark>class=&quot;value&quot;</mark>&gt;20:00&lt;/span&gt;&lt;/span&gt; at 
  &lt;a <mark>class=&quot;location url&quot;</mark> href=&quot;http://www.apple.com/jp/retail/ginza/map/&quot;&gt;
  Apple Ginza&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</code></pre>
<blockquote><div class="vevent">
  <h3><a class="url summary" href="http://atnd.org/events/5181">WDE-ex Vol.11 — Designing for iPad</a>: Our experience so far</h3>
  <p><span class="dtstart"><abbr class="value" title="2010-07-21">July 21st</abbr> <span class="value">19:00</span></span>-<span class="dtend"><span class="value">20:00</span></span> at <a class="location url" href="http://www.apple.com/jp/retail/ginza/map/">Apple Ginza</a></p>
</div></blockquote>
<figcaption>Example hCard-formatted event, including a sample rendering</figcaption>
</figure>

<p>We’ve added <code>vevent</code> on a wrapping element to indicate this is an hCalendar. Events are required to have a summary and a starting time, so we’ve added <code>summary</code> and indicated the starting date and time using <code>dtstart</code>. While historically datetimes were indicated using <code>&lt;abbr title=""&gt;</code>, the required <a href="http://microformats.org/wiki/iso-8601" title="iso-8601 · Microformats Wiki">ISO 8601 format</a> (for example “<code>2010-07-10T19:01:29</code>”) is very unfriendly to screen readers. Imagine having those numbers read to you! For this reason, the <a href="http://microformats.org/wiki/hcalendar" title="hCalendar 1.0 · Microformats Wiki">hCalendar specification</a> recommends either breaking the datetime into separate date and time pieces, using the <a href="http://microformats.org/wiki/value-class-pattern" title="Value Class Pattern &middot; Microformats Wiki">value class pattern</a>, or possibly doing both. The specification is also smart enough to know that if the end datetime <code>dtend</code> is only a time, then it’s on the same day, so we don’t need to specify the date again, although tool support for this is spotty. Finally, we’ve added some <abbr>URL</abbr>s, one of which is for the event’s location.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2010/07/operator-hcalendar-debug.png" alt="The Firefox Operator plugin’s debug window, showing information about the current hCalendar" width="383" height="238">
<figcaption>The Firefox plugin Operator’s debug view, showing the microformat properties it has recognised</figcaption>
</figure>

<p>With this data now being machine-readable, we can <em>do things</em> with it. For example, we can add the event to a calendar app with one click.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2010/07/operator-hcalendar.png" alt="The Firefox Operator plugin’s options for hCalendar-formatted content" width="541" height="172">
<figcaption>Operator can save hCalendar-formatted content as an ical file (for easy importing into your address book software), or add it to various online calendars</figcaption>
</figure>
</section><!-- /#hcalendar -->
</section><!-- /#lightning -->

<section id="uf-in-html5">
<h2>Using microformats in <abbr>HTML</abbr>5</h2>

<p>So now we’ve had a whistle-stop introduction to microformats and gotten a glimpse of the benefits they provide. The question is: Can we use them in <abbr>HTML</abbr>5 pages? Let’s start with the good news.</p>

<p>As most microformats use only <code>class</code> and/or <code>rel</code> — basic parts of <abbr>HTML</abbr> that remain unchanged in HTML5 — <strong>these microformats are completely fine in <abbr>HTML</abbr>5</strong>. Yay! However there are a few wrinkles to keep us on our toes.</p>

<section id="votelinks">
<h3>The <code>rev</code>-based VoteLinks microformat</h3>

<p>One of the things that’s been cut in <abbr>HTML</abbr>5 is the <code>rev</code> attribute, which was the reverse relationship of <code>rel</code>. On the question of whether microformats should use <code>rev</code>, the <a href="http://microformats.org/wiki/rev#Should_rev_even_be_used" title="rel-faq · Microformats Wiki">microformats wiki</a> states:</p>

<blockquote><p>The short answer is unfortunately “NO”. Use of “rev” should be avoided. However, VoteLinks’ use of rev has been grandfathered since it was such an early use.</p>
<footer><cite><a href="http://microformats.org/wiki/rev#Should_rev_even_be_used" title="rel-faq · Microformats Wiki">Rel <abbr>FAQ</abbr> — Microformats wiki</a></cite></footer></blockquote>

<p>The <a href="http://microformats.org/wiki/vote-links" title="Vote Links · Microformats Wiki">VoteLinks specification</a> mentioned here allowed us to add <code>vote-for</code>, <code>vote-against</code>, or <code>vote-abstain</code> values to a link via the <code>rev</code> attribute, indicating agreement, disagreement, or indifference (respectively) toward the destination <abbr>URL</abbr>. However, as the default state of a link is an implicit vote of agreement, and as the rel-nofollow link microformat is equivalent to <code>vote-abstain</code>, the only one we’re unable to replicate is <code>vote-against</code> (no link? ;-) ). I expect that the microformats community will eventually come up with <code>rel</code>-based equivalent names for VoteLinks, but until then you’ll need to avoid this microformat when using <abbr>HTML</abbr>5.</p>
</section><!-- /#votelinks -->


<section id="profile">
<h3>The <code>profile</code> attribute</h3>

<p>The <code>profile</code> attribute is obsolete in <abbr>HTML</abbr>5, as it was determined unnecessary. Currently, microformat profiles are very rarely used in the wild and are not required, so this probably won’t affect you.</p>
<!-- 
Ian Hickson wrote:
Summary: profile="" doesn't work in practice so we have dropped it. We haven't replaced it with anything since there isn't really a problem to solve - conflicts don't occur in practice, as Microformat names are picked to be rather unique and recognisable. The market takes care of problems like this without the need for namespace syntax.
—WHATWG email list, Wed, May 7, 2008 at 11:27 PM
-->
</section><!-- /#profile -->

<section id="uf-wiki">
<h3>Microformats specifications vs <abbr>HTML</abbr>5</h3>

<p>While microformats using <code>class</code> and <code>rel</code> work fine, some of the new features in <abbr>HTML</abbr>5 aren’t supported yet. The <a href="http://microformats.org/wiki/html5" title="Microformats in HTML 5 · Microformats Wiki">Microformats in <abbr>HTML</abbr>5</a> page on the microformats wiki currently begins:</p>

<blockquote><p>This page is to document <strong>future</strong> use of microformats in <abbr>HTML</abbr> 5. None of the items documented are supported now, and may change upon proper development within the microformats community, or changes in the <abbr>HTML</abbr> 5 specification.</p>
<footer><cite><a href="http://microformats.org/wiki/html5" title="Microformats in HTML 5 · Microformats Wiki">Microformats in <abbr>HTML</abbr>5 — Microformats wiki</a></cite></footer></blockquote>

<p>This includes the <a href="http://html5doctor.com/the-time-element/" title="The time element (and microformats) | HTML5 Doctor">nifty new <code>&lt;time datetime=""&gt;</code> element</a>, which would be perfect for microformat times, such as <code>dtstart</code> and <code>dtend</code> in the hCalendar microformat. It’s also true for adding microformats via microdata rather than <code>class</code> and <code>rel</code>. There has been talk of a general way to map any microformat into microdata, but this hasn’t eventuated as of yet.</p>
</section><!-- /#uf-wiki -->

<section id="uf-tools">
<h3>Microformats-consuming tools (or, the problem with <abbr>HTML</abbr> Tidy)</h3>

<p>The microformats wiki’s warning about <code>&lt;time&gt;</code> brings us to another caveat: tool support. Even if <code>&lt;time datetime=""&gt;</code> was valid in the microformats spec, at present most of the microformats tools can’t get this information from the <code>datetime=""</code> attribute. Now, you <em>could</em> wrap <code>&lt;time datetime=""&gt;</code> around a microformats <code>dtstart</code> or <code>dtend</code>:</p>

<pre><code>&lt;time datetime=&quot;2010-07-21T19:00:00+09:00&quot;&gt;&lt;span class=&quot;dtstart&quot;&gt;
  &lt;abbr class=&quot;value&quot; title=&quot;2010-07-21&quot;&gt;July 21st&lt;/abbr&gt;
  &lt;span class=&quot;value&quot;&gt;19:00
&lt;/span&gt;&lt;/span&gt;&lt;/time&gt;</code></pre>

<p>However, as the <code>&lt;time datetime=""&gt;</code> data is then not explicitly part of the microformat, doing this isn’t really getting you anywhere, except bloated code-ville.</p>

<div class="callout changed-block">
<p>The problem is actually way worse as many tools use the parser <a href="http://tidy.sourceforge.net/" title="HTML Tidy Project Page"><abbr>HTML</abbr> Tidy</a> (“last updated March 2009”!), which <a href="http://lists.w3.org/Archives/Public/html-tidy/2010JanMar/0005.html" title="Re: teach tidy new attributes ?? from Bjoern Hoehrmann on 2010-02-02 (html-tidy@w3.org from January to March 2010)">probably won’t be fixed for new <abbr>HTML</abbr>5 elements</a>. This means <em>any</em> microformats classes on new <abbr>HTML</abbr>5 elements will be ignored. The potential alternative <a href="http://code.google.com/p/html5lib/" title="html5lib - Project Hosting on Google Code">html5lib.php</a> is still pretty young. You can get around this by wrapping <abbr>HTML</abbr>5 elements in <code>&lt;div&gt;</code>s and <code>&lt;spans&gt;</code> and applying the microformats classes to them, but that’s hardly ideal.</p>

<p>However, there’s a ray of sunshine here. The tool you’ll most want to use is <a href="http://dev.h2vx.com/" title="H2VX">H2VX.com</a> — it converts hCard and hCalendar microformats into vcard and ical files for users to download and add to their address books and calendars, respectively. While h2vx.com uses Tidy, Tantek Çelik and Brian Suda (the maintainers of H2VX) have a version of H2VX that <strong>does</strong> work with HTML5 elements and <code>&lt;time&gt;</code>’s <code>datetime</code> attribute. We’re saved! Check it out at <a href="http://dev.h2vx.com/" title="H2VX">dev.h2vx.com</a>.</p>
</div>

<section id="uf-tools-table">
<h4>Microformats Tool support</h4>
<table>
<thead><tr><th></th><th><a href="https://addons.mozilla.org/en-US/firefox/addon/4106/">Operator</a></th><th><a href="http://microformatique.com/optimus/" title="Optimus—Microformats Transformer">Optimus</a></th><th><a href="http://h2vx.com/" title="H2VX">h2vx.com</a></th><th><ins><a href="http://dev.h2vx.com" title="H2VX">dev.h2vx.com</a></ins></th></tr></thead>
<tbody>
<tr><th>can use classes on <abbr>HTML</abbr>5 elements</th><td>yes</td><td>yes<!-- todo: re-check --></td><td>no</td><td><ins>yes</ins></td></tr>
<tr><th>supports <abbr>HTML</abbr>5’s <code>&lt;time&gt;</code></th><td>no</td><td>no</td><td>no</td><td><ins>yes</ins></td></tr>
<tr><th>Understands the value class pattern</th><td>yes</td><td>no</td><td>yes</td><td><ins>yes</ins></td></tr>
<tr><th>Understands implied <code>dtend</code></th><td>yes</td><td>no</td><td><ins>yes</ins></td><td><ins>yes</ins></td></tr>
<tr><th>Understands timezones</th><td>yes</td><td>yes</td><td><ins>yes</ins></td><td><ins>yes</ins></td></tr>
</tbody>
</table>

<p>I didn’t expect anyone to support <code>&lt;time&gt;</code> until it became part of a microformat specification. Given how &hellip; <em>non-micro</em> expressing datetimes is in microformats currently, I am very thankful H2VX has in <a href="http://dev.h2vx.com" title="H2VX">dev.h2vx.com</a>!</p>
</section> <!-- /#uf-tools-table -->
</section> <!-- /#uf-tools -->

</section> <!-- /#uf-in-html5 -->

<section id="conclusion">
<h2>Conclusion</h2>

<p>So where does that leave us? Well, if you keep the above caveats in mind <strong>you can safely use microformats in <abbr>HTML</abbr>5</strong>. Google has no problem with microformats in <abbr>HTML</abbr>5, even on new elements, and I’m under the impression that Yahoo is the same. However, remember that if you want to offer a “click to download” link via H2VX, you’ll have to use <a href="http://dev.h2vx.com" title="H2VX">dev.h2vx.com</a>.</p>

<p id="controversy">An important thing to note about microformats: as wonderful as they are, the current method of using the plain old semantic <abbr>HTML</abbr> tools of <code>class</code>, <code>rel</code>, and coding patterns is something of a brilliant hack. The use of <code>class</code> (an <span title="arbitrary HTML extension point for authors">author playground</span>) and the lack of use/demise of <code>profile</code>, combined with the complexity of coding to detect for microformats in the wild, means that native browser support is unlikely anytime soon<!-- another possible reason is that no browser makers care enough to implement support -->. There was the expectation that at some stage there’d be a better way to easily add extra semantic information for others to use. In future articles, we’ll look at <a href="http://html5doctor.com/microdata/" title="Extending HTML5 — Microdata | HTML5 Doctor">microdata</a> and <abbr>RDFa</abbr>, and see what they have to offer over plain old semantic <abbr>HTML</abbr>.</p>

<p>If you have common types of data in your content that are covered by a microformat, and you want to make them machine-readable for others (and who wouldn’t), you should definitely consider using microformats in <abbr>HTML</abbr>5. Adding microformats is basically adding a lightweight <abbr>API</abbr> to your content, and is simple enough that <em>even a designer</em> can do it! This helps search engines and savvy users to more easily use your content. Check out the <a href="http://microformats.org/wiki/" title="Welcome to the microformats wiki! · Microformats Wiki">microformats wiki</a>, grab the indispensable <a href="http://suda.co.uk/projects/microformats/cheatsheet/" title="suda.co.uk/projects/microformats [Cheat Sheet]">microformats cheat sheet</a> by <a href="http://twitter.com/briansuda" title="@briansuda">Brian Suda</a>, peruse these books and DVDs on microformats, and start getting (even more) semantic!</p>

<section id="ref">
<h3>Books and DVDs</h3>
<ul class="amazon">
<li><img src="http://html5doctor.com/wp-content/uploads/2010/08/microformats_ja.jpg" alt="Microformats: Empoering your markup" width="50" height="75" />Microformats: Empowering Your Markup for Web 2.0 — John Allsopp<br />
<div class="amzshcs" id="amzshcs-8a874135a3ce872dc17872b6e19a8bb8"><span class="amzshcs-item" id="amzshcs-item-ca3b214c4f8566611bd6690219fa2a2b"> <a href="http://www.amazon.co.uk/Microformats-Empowering-Your-Markup-Web/dp/1590598148%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1590598148">Amazon UK</a></span></div> | <div class="amzshcs" id="amzshcs-5055b9f29c7cba51ba1714e0f05b3fc9"><span class="amzshcs-item" id="amzshcs-item-adc0339bcd4414e99f890aa52e5b13d7"> <a href="http://www.amazon.com/Microformats-Empowering-Your-Markup-Web/dp/1590598148%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1590598148">Amazon US</a> </span></div> | <div class="amzshcs" id="amzshcs-b574af46f845bc576c4028e3d20910d3"><span class="amzshcs-item" id="amzshcs-item-6a0697ac150924872e2d35f2e763a0c3"> <a href="http://www.amazon.de/Microformats-Empowering-Your-Markup-Web/dp/1590598148%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1590598148">Amazon DE</a> </span></div> | <div class="amzshcs" id="amzshcs-b9418b3f4b0ca6700027f76f19a2f2da"><span class="amzshcs-item" id="amzshcs-item-3ba74a4b213b831047f748be6bc8e4d6"> <a href="http://www.amazon.co.jp/Microformats-Empowering-Your-Markup-Web/dp/1590598148%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1590598148">Amazon JP</a> </span></div> | <div class="amzshcs" id="amzshcs-8ca2f799ff27ab30f84242cf8d7d646c"><span class="amzshcs-item" id="amzshcs-item-edefeeefe744fbb240365caa2f62be2b"> <a href="http://www.amazon.co.jp/%E3%83%9E%E3%82%A4%E3%82%AF%E3%83%AD%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88-%7EWeb%E3%83%9A%E3%83%BC%E3%82%B8%E3%82%92%E3%82%88%E3%82%8A%E4%BE%BF%E5%88%A9%E3%81%AB%E3%81%99%E3%82%8B%E6%9C%80%E6%96%B0%E3%83%9E%E3%83%BC%E3%82%AF%E3%82%A2%E3%83%83%E3%83%97%E3%83%86%E3%82%AF%E3%83%8B%E3%83%83%E3%82%AF%7E-Web-Designing-BOOKS/dp/4839925445%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D4839925445">Amazon JP (日本語版)</a> </span></div></li>
<li><img src="http://html5doctor.com/wp-content/uploads/2010/08/microformats_ac.jpg" alt="Designning with Microformats" width="50" height="75" />Designing with Microformats for a Beautiful Web (DVD) — Andy Clarke<br />
<div class="amzshcs" id="amzshcs-95f1b9b80bde174f6f9c9d7ee9f9d59e"><span class="amzshcs-item" id="amzshcs-item-554c5b0c2e314aba0ce5f9a303a79773"> <a href="http://www.amazon.co.uk/DESIGNING-MICROFORMATS-BEAUTIFUL-WEB/dp/0321680146%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321680146">Amazon UK</a> </span></div> | <div class="amzshcs" id="amzshcs-efcffcf308e8a6c623ce78e4bc7f7cd6"><span class="amzshcs-item" id="amzshcs-item-a7fc05944786e81d5d79eed14e4ac61d"> <a href="http://www.amazon.com/Designing-Microformats-Beautiful-Andy-Clarke/dp/0321680146%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321680146">Amazon US</a> </span></div> | <div class="amzshcs" id="amzshcs-d0ce2f4154e95bfae6274f8a6897b158"><span class="amzshcs-item" id="amzshcs-item-33522c588d14e9934a0d834285ae380a"> <a href="http://www.amazon.de/Designing-Microform-Ats-Beautiful-Book/dp/0321680146%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321680146">Amazon DE</a> </span></div> | <div class="amzshcs" id="amzshcs-32b039997ba527fbd9157def627f4dd5"><span class="amzshcs-item" id="amzshcs-item-9468700ba7f9e93e03416265f7ff3cec"> <a href="http://www.amazon.co.jp/Designing-Microformats-Beautiful-Voices-Matter/dp/0321680146%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321680146">Amazon JP</a> </span></div></li>
<li><img src="http://html5doctor.com/wp-content/uploads/2010/08/microformats_el.jpg" alt="Microformats Made Simple" width="50" height="75" /> Microformats Made Simple — Emily P. Lewis and Tantek Celik<br />
<div class="amzshcs" id="amzshcs-09639a7f48fb10d8f851ab7d3e86be26"><span class="amzshcs-item" id="amzshcs-item-0fe33ff215f833e24d23fdbd33512644"> <a href="http://www.amazon.co.uk/Microformats-Made-Simple-Emily-Lewis/dp/0321660773%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321660773">Amazon UK</a> </span></div> | <div class="amzshcs" id="amzshcs-b9a1200a9484c14ac7b0205999c2af7d"><span class="amzshcs-item" id="amzshcs-item-91c60b321652ee65e6b68ea1bbed534f"> <a href="http://www.amazon.co.uk/Microformats-Made-Simple-Emily-Lewis/dp/0321660773%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321660773">Amazon US</a> </span></div> | <div class="amzshcs" id="amzshcs-bf7926010bfcfb17c6d7ef8f864b817b"><span class="amzshcs-item" id="amzshcs-item-540e55e65c683a64f6376981f34766a6"> <a href="http://www.amazon.de/Microformats-Made-Simple-Emily-Lewis/dp/0321660773%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321660773">Amazon DE</a> </span></div> | <div class="amzshcs" id="amzshcs-99d06a2264916bda2ba2341b25df7ca1"><span class="amzshcs-item" id="amzshcs-item-e8ae9d804c21a13653d24d727ff5de1d"> <a href="http://www.amazon.co.jp/Microformats-Made-Simple-Emily-Lewis/dp/0321660773%3FSubscriptionId%3DAKIAIFYRWAKK7IFCGGSQ%26tag%3Dhtml5doctor-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321660773">Amazon JP</a> </span></div></li>
</ul>
</section> <!-- /#ref -->
</section> <!-- /#conclusion -->

<section id="changes">
<h2>Changes <a class="permalink" href="#changes">#</a></h2>
<ol class="semantic-list">
<li><time datetime="2011-09-23T01:10:04+12:00"><em>2011-09-23</em></time> Minor copyedits and the major addition of <a href="http://dev.h2vx.com" title="H2VX">dev.h2vx.com</a> support, with thanks and apologies for the delay to Brian Suda and Tantek Çelik.</li>
</ol>
<!-- /#changes --></section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/the-address-element/" rel="bookmark" class="crp_title">The Address Element</a></li><li><a href="http://html5doctor.com/the-time-element/" rel="bookmark" class="crp_title">The time element (and microformats)</a></li><li><a href="http://html5doctor.com/microdata/" rel="bookmark" class="crp_title">Extending HTML5 — Microdata</a></li><li><a href="http://html5doctor.com/time-and-data-element/" rel="bookmark" class="crp_title">Goodbye time, datetime, and pubdate. Hello data and value.</a></li><li><a href="http://html5doctor.com/u-element/" rel="bookmark" class="crp_title">The return of the u element</a></li></ul></div><p><a href="http://html5doctor.com/microformats/" rel="bookmark">Extending HTML5 — Microformats</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on August 17, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/microformats/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Video: the track element and webM codec</title>
		<link>http://html5doctor.com/video-the-track-element-and-webm-codec/</link>
		<comments>http://html5doctor.com/video-the-track-element-and-webm-codec/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 13:45:42 +0000</pubDate>
		<dc:creator>Bruce Lawson</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[multimedia]]></category>
		<category><![CDATA[codec]]></category>
		<category><![CDATA[track]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[webm]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2089</guid>
		<description><![CDATA[There are a couple of interesting developments in the world of HTML5 multimedia that you'll be interested in&#8212;the webM video format, and a proposed solution to HTML5 multimedia accessibility.]]></description>
			<content:encoded><![CDATA[<p>There are a couple of interesting developments in the world of <abbr>HTML</abbr>5 multimedia that you&#8217;ll be interested in. The first is the new <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#the-track-element"><code>&lt;track&gt;</code> element</a> (currently only in the WHAT-WG spec due to political stuff).</p>

<p><code>&lt;track&gt;</code> is a child of a <code>&lt;video&gt;</code> or <code>&lt;audio&gt;</code> element that links to a <b>timed track</b>, or time-based data. The kind of data is set via a <code>kind</code> attribute, which can take values of <code>subtitles</code>, <code>captions</code>, <code>descriptions</code>, <code>chapters</code> or <code>metadata</code>, depending on the type of information you&#8217;re adding to your media. These point to a source file containing timed text that the browser will expose via some kind of user interface, if the visitor requires additional data.</p>

<p>This will allow for &#8220;write once, use everywhere&#8221; accessibility; anyone linking to that file with a <code>&lt;video&gt;</code> or <code>&lt;audio&gt;</code> element that includes the element can access your information.</p>

<pre><code>&lt;track kind=captions src=blah.srt&gt;</code></pre>

<p>The file format is a new format called <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#websrt">WebSRT</a>, which competes with about <a href="http://wiki.whatwg.org/wiki/Timed_track_formats">50 other timed formats</a>, including some W3C formats (hence the omission of <code>&lt;track&gt;</code> from the W3C spec).</p><p>Added 9 July 2010: Here&#8217;s a readable <a href="http://www.delphiki.com/websrt/">overview of the SRT format</a>.</p>

<p>Given that the format itself isn&#8217;t fully specified yet, it will be a while until we see implementation in browsers. But it&#8217;s good to know that there will be an official way to add accessibility information to media. Until then, I have a <a href="http://dev.opera.com/articles/view/accessible-html5-video-with-javascripted-captions/">JavaScript hack</a> to take timed <code>&lt;span&gt;</code>s out of an in-page transcript to superimpose over a video.</p>

<h2>WebM video format</h2>
<p>The big news of the last month is that Google open-sourced the VP8 video codec that it acquired when it <a href="http://investor.google.com/releases/2010/0219.html">took over On2 Technologies</a>. When combined with the Vorbis audio codec (that Spotify uses) and wrapped in a subset of the <a href="http://en.wikipedia.org/wiki/Matroska">Matroska container format</a>, it&#8217;s collectively known as <a href="http://www.webmproject.org/">WebM</a>.</p>

<p>All YouTube videos are being transcoded to WebM, and Adobe have also announced they will include it in their Flash player. It&#8217;s available in an <a href="http://www.opera.com/browser/next">Opera 10.60 beta</a>, a <a href="http://nightly.mozilla.org/webm/">Firefox testing build</a>, and a <a href="http://www.chromium.org/getting-involved/dev-channel">Chromium dev channel</a>. Even Microsoft have said that IE9 will support it if the codec is installed on the computer.</p>

<p>The <a href="http://www.streamingmedia.com/Articles/Editorial/Featured-Articles/First-Look-H.264-and-VP8-Compared-67266.aspx">VP8 video codec itself is high-quality</a> (Google had said that Ogg Theora wasn&#8217;t good enough compression-to-quality for YouTube, but Theora was based on the VP3 precursor to VP8). It&#8217;s available for <a href="http://zaheer.merali.org/articles/2010/06/02/webm-and-vp8-streaming-live-from-flumotion/">streaming</a> too.</p>

<p>If you want to encode to WebM, you can try the <a href="http://www.mirovideoconverter.com/">Miro Video Converter</a> utility. Although it doesn&#8217;t allow you to optimise settings, it&#8217;s very easy to use. As the codec becomes more widespread, expect to see many more tools for content creation, editing, and transcoding.</p>

<p>Once production versions of the browsers are available, you should encode your videos with WebM as the first option, Ogg for older versions of Opera, Firefox and Chrome, falling back to royalty-encumbered H.264 for Safari and links to downloads or a Flash player for legacy browsers:</p>

<pre><code>&lt;video controls&gt;
&lt;source src=video.webm type='video/webm; codecs="vorbis,vp8"'&gt;
&lt;source src=video.mp4 type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'&gt;
&lt;source src=video.ogv type='video/ogg; codecs="theora, vorbis"'&gt;
&lt;!-- embed Flash here --&gt;
&lt;p&gt;Your browser does not support video; download the &lt;a href=&quot;video.webm&quot;&gt;WebM&lt;/a&gt;, &lt;a href=&quot;video.mp4&quot;&gt;mp4&lt;/a&gt; or &lt;a href=&quot;video.ogg&quot;&gt;Ogg&lt;/a&gt; video for off-line viewing.&lt;/p&gt;
&lt;/video&gt;</code>
</pre>

<p>If, however, you&#8217;re having problems with the iPad, put the MP4 version first in the <code>&lt;source&gt;</code> element; apparently there&#8217;s a bug that causes the iPad only to see the first <code>&lt;source&gt;</code> element.</p>

<p>It’s a long haul, and it’s not over yet, but <code>&lt;track&gt;</code> and .webM show significant progress towards our goal of accessible, open, and royalty-free video playing natively in the browser.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/video-subtitling-and-webvtt/" rel="bookmark" class="crp_title">Video Subtitling and WebVTT</a></li><li><a href="http://html5doctor.com/youtube-and-vimeo-support-html5-video/" rel="bookmark" class="crp_title">YouTube and Vimeo support HTML5 Video</a></li><li><a href="http://html5doctor.com/the-video-element/" rel="bookmark" class="crp_title">The video element</a></li><li><a href="http://html5doctor.com/native-audio-in-the-browser/" rel="bookmark" class="crp_title">Native Audio in the browser</a></li><li><a href="http://html5doctor.com/review-html5-now-dvd/" rel="bookmark" class="crp_title">Review: HTML5 Now (DVD)</a></li></ul></div><p><a href="http://html5doctor.com/video-the-track-element-and-webm-codec/" rel="bookmark">Video: the track element and webM codec</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on June 24, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/video-the-track-element-and-webm-codec/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
	</channel>
</rss>

