<?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; Oli Studholme</title>
	<atom:link href="http://html5doctor.com/author/olib/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>The ol Element and Related Attributes: type, start, value, and reversed</title>
		<link>http://html5doctor.com/ol-element-attributes/</link>
		<comments>http://html5doctor.com/ol-element-attributes/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 14:30:52 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[li]]></category>
		<category><![CDATA[ol]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=4397</guid>
		<description><![CDATA[<p>The <code>&#60;ol&#62;</code> element has a new attribute <code>reversed</code> in HTML5. In addition, a couple of related attributes purged in HTML 4 have made a return, namely <code>start</code> and <code>type</code> for <code>&#60;ol&#62;</code>, and <code>value</code> for <code>&#60;li&#62;</code>. Making things more interesting, the returning attributes were removed from HTML 4 for being presentational. So why are they back? Let’s investigate…</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-ol-element" title="4.5 Grouping content — HTML Standard">The <code>&lt;ol&gt;</code> element has a new attribute <code>reversed</code></a> in HTML5. In addition, a couple of related attributes purged in HTML 4 have made a return, namely <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#attr-ol-start" title="4.5 Grouping content — HTML Standard"><code>start</code></a> and <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#attr-ol-type" title="4.5 Grouping content — HTML Standard"><code>type</code></a> for <code>&lt;ol&gt;</code>, and <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-li-element" title="4.5 Grouping content — HTML Standard"><code>value</code> for <code>&lt;li&gt;</code></a>. Making things more interesting, the returning attributes were <a href="http://www.w3.org/TR/html4/appendix/changes.html#h-A.3.2" title="HTML 4 Changes">removed from HTML 4 for being presentational</a>. So why are they back? Let’s investigate…</p>

<section id="presentational-and-semantic">
<h2>Presentational <em>and</em> semantic? <a class="permalink" href="#presentational-and-semantic">#</a></h2>

<p>As we all know, presentational stuff belongs in CSS, not HTML. In HTML 4.01, the <code>type</code> attribute was replaced by <code>list-style-type</code>, and the <code>start</code> and <code>value</code> attributes were dropped, with only the potential (although fiddly) replacement in some cases of <a href="http://dev.w3.org/csswg/css3-content/#counters" title="CSS Generated Content Module Level 3">CSS generated content-based counters</a>. So why would we want to specify “presentational” stuff like a list’s style in our HTML?</p>

<section id="type-attribute">
<h3>The <code>type</code> Attribute <a class="permalink" href="#type-attribute">#</a></h3>

<p>While an ordered list’s counter style is generally presentational, in some documents it can be a part of the document’s <em>meaning</em>, as the specification for the <code>type</code> attribute notes:</p>

<figure>
<blockquote>
The <code>type</code> attribute can be used to specify the kind of marker to use in the list, in the cases where that matters (e.g. because items are to be referenced by their number/letter).
</blockquote>
<figcaption>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#attr-ol-type">HTML: Living Standard</a></cite>, <abbr>WHATWG</abbr></figcaption>
</figure>

<p>Examples of this include legal or technical documents, which can contain references to non-decimal list items in prose:</p>

<figure>
<blockquote id="legalese">
<style scoped>/* yeah, just faking it here for demonstration purposes */
#legalese div {margin-left: 3em;}
#legalese .point-3-3:before {
  display: block;
  position: absolute;
  content: "3.3 ";
  left: -3em;
}
</style>
<div class="point-3-3"><b>Obligations of the Company – Tranche One</b><br />
Subject to satisfaction of <mark>clause 3.2(a)</mark>, on Tranche One Completion the Company will:</div>
<div>(a) Purchase a foosball table for staff use</div>
<div>(b) …</div>
</ol>
</blockquote>
<figcaption>Mockup of an example legal document with a highlighted reference to a non-decimal list item</figcaption>
</figure>

<p>We can specify the list’s style using the <code>type</code> attribute, with the following values:</p>

<table>
<caption><code>type</code> attribute values and their corresponding list counter types</caption>
<thead>
<tr><th scope="col"><code>&lt;ol type=""&gt;</code> values</th><th scope="col">Equivalent <code>list-style-type</code></th></tr>
</thead>
<tbody>
<tr><th scope="row"><code>type="1"</code></th><td><code>decimal</code> (default style)</td></tr>
<tr><th scope="row"><code>type="a"</code></th><td><code>lower-alpha</code></td></tr>
<tr><th scope="row"><code>type="A"</code></th><td><code>upper-alpha</code></td></tr>
<tr><th scope="row"><code>type="i"</code></th><td><code>lower-roman</code></td></tr>
<tr><th scope="row"><code>type="I"</code></th><td><code>upper-roman</code></td></tr>
</tbody>
</table>

<p>Further emphasising that this is not a general alternative to <code>list-style-type</code>, only these five list styles are available, whereas <a href="http://www.w3.org/TR/CSS2/generate.html#list-style" title="Generated content, automatic numbering, and lists">CSS 2.1 defines eleven <code>&lt;ol&gt;</code> list styles</a>. If you’re not referring to list counters in your prose, or even if you are but you’re just using the default decimal list counters, then you should use CSS over the <code>type</code> attribute. However, if the list counter type has a semantic meaning, HTML is the place to put it. Note that CSS <code>list-style-type</code> will override HTML <code>type</code> attribute values, so they’ll only work if you <em>haven’t</em> specified a <code>list-style-type</code> in your CSS.</p>

<!-- /#type-attribute --></section>

<section id="start-value-attribute">
<h3>The <code>start</code> and <code>value</code> Attributes <a class="permalink" href="#start-value-attribute">#</a></h3>

<p>The <code>start</code> attribute lets us set a list’s first counter. It’s handy for lists that must be split over several <code>&lt;ol&gt;</code> elements, by allowing us to continue the list item numbering from where the previous list left off. The related <code>value</code> attribute is used on an <code>&lt;li&gt;</code> element, and lets us manually number list items. <code>value</code> on the first list item also overrides <code>start</code>. A subsequent <code>&lt;li&gt;</code> element <em>without</em> <code>value</code> will increment the previous <code>value</code> by one.</p>

<figure>
<blockquote>
The first item in the list has the ordinal value given by the <code>ol</code> element’s <code>start</code> attribute, unless that <code>li</code> element has a <code>value</code> attribute with a value that can be successfully parsed, in which case it has the ordinal value given by that <code>value</code> attribute.
</blockquote>
<figcaption>— <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-ol-element" title="4.5 Grouping content — HTML Standard"><cite>HTML: Living Standard</cite></a>, <abbr>WHATWG</abbr></figcaption>
</figure>

<p>Here’s an example of how you could use <code>start</code> or <code>value</code> to continue a list, which also demonstrates <code>type</code>:</p>

<figure>
<pre><code>&lt;!-- Continuing a previous list with value="" --&gt;
&lt;ol type="I"&gt;
  &lt;li value="7"&gt;seventh item&lt;/li&gt;
  &lt;li&gt;eighth item&lt;/li&gt;
  &lt;li&gt;ninth item&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- Continuing a previous list with start="" --&gt;
&lt;ol type="I" start="7"&gt;
  &lt;li&gt;seventh item&lt;/li&gt;
  &lt;li&gt;eighth item&lt;/li&gt;
  &lt;li&gt;ninth item&lt;/li&gt;
&lt;/ol&gt;
</code></pre>
<div class="column">
<ol type="I">
  <li value="7">seventh item <span class="meta">(using <code>&lt;li value="7"&gt;</code>)</span></li>
  <li>eighth item</li>
  <li>ninth item</li>
</ol>
<ol type="I" start="7">
  <li>seventh item <span class="meta">(using <code>&lt;ol start="7"&gt;</code>)</span></li>
  <li>eighth item</li>
  <li>ninth item</li>
</ol>
</div>
<figcaption>Using <code>value</code> and <code>start</code> to continue a previous list of six items</figcaption>
</figure>

<p>While both of these attributes give us more control, they unfortunately also mean adding or removing list items can make your <code>start</code> or <code>value</code>-based numbering appear broken, so in general you’ll probably want to avoid them and <a href="http://dev.opera.com/articles/view/automatic-numbering-with-css-counters/" title="Automatic numbering with CSS Counters - Dev.Opera">investigate CSS generated content counters</a> instead. You’ll need to use generated content counters if you want to make “1.1.1”-style nested list counters too.</p>

<!-- /#start-value-attribute --></section>

<!-- /#presentational-and-semantic --></section>

<section id="reverse">
<h2>Counting It Down with <code>reverse</code> <a class="permalink" href="#reverse">#</a></h2>

<p>The new attribute <code>reverse</code> allows us to make ordered lists that count <em>down</em> rather than up. If you’re coding a top ten countdown or you’re a space junkie, it’s the attribute you’ve always wanted.</p>

<figure>
<blockquote>
The reversed attribute is a boolean attribute. If present, it indicates that the list is a descending list (..., 3, 2, 1).
</blockquote>
<figcaption>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#attr-ol-reversed">HTML: Living Standard</a></cite>, <abbr>WHATWG</abbr></figcaption>
</figure>

<p>By default, <code>&lt;ol reversed&gt;</code> starts from the total number of list items and counts down to one, so there’s no need to also specify <code>start</code> unless you want something different to happen. Unfortunately, as we’ll see in the <a href="#browser-support">browser support table</a> in just a moment, none of them do yet, so in the meantime you can make a reversed list by manually specifying each list item’s number with <code>value</code> (as you can see in the following example) or via CSS counters.</p>

<figure>
<pre><code>&lt;!-- default list --&gt;
&lt;ol&gt;
  &lt;li&gt;three&lt;/li&gt;
  &lt;li&gt;two&lt;/li&gt;
  &lt;li&gt;one&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- using the reversed attribute (will look the same as the third list in a supporting browser) --&gt;
&lt;ol reversed&gt;
  &lt;li&gt;three&lt;/li&gt;
  &lt;li&gt;two&lt;/li&gt;
  &lt;li&gt;one&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- using value attributes on li --&gt;
&lt;ol&gt;
  &lt;li value="3"&gt;three&lt;/li&gt;
  &lt;li value="2"&gt;two&lt;/li&gt;
  &lt;li value="1"&gt;one&lt;/li&gt;
&lt;/ol&gt;</code></pre>
<div class="columns">
<ol>
<li>three</li>
<li>two</li>
<li>one</li>
</ol>
<ol reversed>
<li>three</li>
<li>two</li>
<li>one</li>
</ol>
<ol>
<li value="3">three</li>
<li value="2">two</li>
<li value="1">one</li>
</ol>
</div>
<figcaption>A normal ordered list, an ordered list with <code>reversed</code>, and an ordered list with each list item numbered manually via <code>value</code></figcaption>
</figure>

<!-- /#reverse --></section>

<section id="browser-support">
<h2>Browser support table <a class="permalink" href="#browser-support">#</a></h2>

<p>Browsers support the <code>start</code>, <code>type</code>, and <code>value</code> attributes as part of supporting legacy content (<a href="http://www.w3.org/TR/REC-html32#ol" title="HTML 3.2 Reference Specification">HTML 3.2 represent!</a>), so we can use them <em>now</em>.</p>

<table class="browser-support centered-data">
<caption>Browser support for <code>type</code>, <code>start</code>, <code>value</code>, and <code>reversed</code> attributes</caption>
<thead>
<tr>
  <th scope="col">Attribute</th>
  <th scope="col"><abbr title="Internet Explorer">IE</abbr></th>
  <th scope="col">Firefox</th>
  <th scope="col">Safari</th>
  <th scope="col">Chrome</th>
  <th scope="col">Opera</th>
</tr>
</thead>
<tbody>
<tr>
  <th scope="row"><code>&lt;ol type=""&gt;</code></th>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
</tr>
<tr>
  <th scope="row"><code>&lt;ol start=""&gt;</code></th>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
</tr>
<tr>
  <th scope="row"><code>&lt;li value=""&gt;</code></th>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
  <td><span title="Yes">✔</span></td>
</tr>
<tr>
  <th scope="row"><code>&lt;ol reversed&gt;</code> <a href="#note-1">¹</a></th>
  <td class="warning"><span title="No">✘</span></td>
  <td class="warning"><span title="No">✘</span> <a href="#note-2">²</a></td>
  <td>5.2 <a href="#note-3">³</a></td>
  <td>18 <a href="#note-3">³</a></td>
  <td class="warning"><span title="No">✘</span></td>
</tr>
</tbody>
</table>

<ol>
<li id="note-1">We can use a JavaScript polyfill to get around the lack of native support for the <code>reversed</code> attribute, such as the <a href="http://www.impressivewebs.com/reverse-ordered-lists-html5/" title="Reverse Ordered Lists in HTML5 | Impressive Webs">polyfill (and accompanying article) from Louis Lazaris</a>, or <a href="https://gist.github.com/1671548">Titani’s polyfills</a>, which both use the <code>value</code> attribute.</li>
<li id="note-2"><ins datetime="2012-02-22T11:15:20+13:00">It’s <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=601912">bug 601912</a>, but there’s no progress as yet</ins></li>
<li id="note-3"><ins datetime="2012-02-22T11:15:20+13:00">Chrome 18 (in the dev channel at the time of writing) has support for <code>reversed</code> (thanks <a href="http://html5doctor.com/ol-element-attributes/#comment-24515">Philip Tellis</a>), as does Safari 5.2 Developer Release (thanks <a href="http://html5doctor.com/ol-element-attributes/#comment-24521">Sam Rayner</a>)</ins></li>
</ol>

<figure>
<pre><code>&lt;!-- default (unsupported) reversed attribute --&gt;
&lt;ol reversed&gt;
  &lt;li&gt;three&lt;/li&gt;
  &lt;li&gt;two&lt;/li&gt;
  &lt;li&gt;one&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- using a reversed attribute polyfill --&gt;
&lt;ol class="polyfill-me" reversed&gt;
  &lt;li&gt;three&lt;/li&gt;
  &lt;li&gt;two&lt;/li&gt;
  &lt;li&gt;one&lt;/li&gt;
&lt;/ol&gt;
</code></pre>
<div>

<div class="column">
<ol reversed>
<li>three <span class="meta">(default list with <code>reversed</code>)</span></li>
<li>two</li>
<li>one</li>
</ol>
<ol class="polyfill-me" reversed>
<li>three <span class="meta">(list with polyfilled <code>reversed</code>)</span></li>
<li>two</li>
<li>one</li>
</ol>
</div>

<script>
// https://gist.github.com/1671548 b.js by Titani
// use this if you want support for browsers which don't have ES5 goodies
(function () {
	if ( 'reversed' in document.createElement('ol') ) {
		return;
	}

	// tweak to target only one list by Oli:
	// var lists = document.getElementsByTagName( 'ol' ); /* commented out */
	var lists = document.getElementsByClassName( 'polyfill-me' ); /* added */

	for ( var i = 0, len = lists.length; i < len; i++ ) {
		if ( lists[i].getAttribute( 'reversed' ) !== null ) {
			reverseList( lists[i] );
		 }
	}

	function reverseList ( list ) {
		var children = [], childNodes = list.childNodes,
			count = list.getAttribute('start'), i, len;

		for ( i = 0, len = childNodes.length; i < len; i++ ) {
                        //Node.ELEMENT_NODE === 1
			if ( childNodes[i].nodeType === 1 ) {
				children.push( childNodes[i] );
			}
		}

		// check to see if a start attribute is provided
		if ( count !== null ) {
			count = Number( count );

			if ( isNaN(count) ) {
				count = null;
			}
		}

		// no, this isn't duplication - start will be set to null
		// in the previous if statement if an invalid start attribute
		// is provided
		if ( count === null ) {
			count = children.length;
		}

		for ( i = 0, len = children.length; i < len; i++ ) {
			children[ i ].value = count--;
		}
	}
}());
</script>

</div>
<figcaption>Our earlier <code>reversed</code> example using a tweaked version of Titani’s <code>&lt;ol reversed&gt;</code> polyfill</figcaption>
</figure>

<p>You can detect for browser support using Modernizr, via the Community add-on “<a href="https://github.com/Modernizr/Modernizr/blob/master/feature-detects/lists-reversed.js">lists-reversed</a>”. If your polyfill was called <code>reversed.js</code> you could load it using the following code:</p>

<pre><code>yepnope({
  test : Modernizr.olreversed,
  nope : ['reversed.js']
});</code></pre>

<p>The <a href="http://www.modernizr.com/download/#-addtest-lists_reversed-load" title="Modernizr Download Builder">custom Modernizr build for doing this</a> would be:</p>

<ul>
<li>Extra > Modernizr.load</li>
<li>Extensibility > Modernizr.addTest</li>
<li>Community add-ons > lists-reversed</li>
</ul>

<!-- /#browser-support --></section>


<section id="conclusion">
<h2>Conclusion <a class="permalink" href="#conclusion">#</a></h2>

<p>These attributes aren’t ones you’ll use often, but sometimes they’ll be just the ticket. They’ll help you avoid adding list item numbering as part of your content (leading to double numbering if your CSS with <code>list-style-type: none;</code> is disabled), or ugly hacks like <code>height:0;</code> on a bunch of filler <code>&lt;li&gt;</code> elements to get the right start value. Even better, <code>type</code>, <code>start</code>, and <code>value</code> are supported and ready to use now.</p>

<p>As usual, just make sure you are only using them where appropriate:</p>

<ul>
<li>Only use <code>type</code> if the list style for counters is semantic, and the document’s meaning will change if your CSS (containing the equivalent <code>list-style-type</code> values) didn’t load.</li>
<li>For <code>start</code>, consider whether your lists could be combined.</li>
<li>Avoid <code>value</code> if at all possible, as it’s less fragile and error-prone to let the browser number list items for you.</li>
<li>Unfortunately, the current lack of browser support means you’ll need to polyfill <code>reversed</code> if you want to use it for now.</li>
</ul>

<p>So what do <em>you</em> think of these new attributes? Have you needed them in the past? Have you actually <em>used</em> some of them back in the day to rock some old-skool <a href="http://www.w3.org/TR/REC-html32#ol" title="HTML 3.2 Reference Specification">HTML 3.2</a>? Will you use them in the future? Let us know in the comments!</p>


<!-- /#conclusion --></section>

<section id="updates">
<h2>Updates <a class="permalink" href="#updates">#</a></h2>
<ol>
<li><em><time datetime="2012-02-22T11:18:24+13:00">2012-02-22</time></em> I’ve added more browser support information and corrections from the comments. Thanks!</li>
</ol>
<!-- /#updates --></section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><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/using-modernizr-to-detect-html5-features-and-provide-fallbacks/" rel="bookmark" class="crp_title">Using Modernizr to detect HTML5 features and provide fallbacks</a></li><li><a href="http://html5doctor.com/the-scoped-attribute/" rel="bookmark" class="crp_title">The scoped attribute</a></li><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/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/ol-element-attributes/" rel="bookmark">The <code>ol</code> Element and Related Attributes: <code>type</code>, <code>start</code>, <code>value</code>, and <code>reversed</code></a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on February 21, 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/ol-element-attributes/feed/</wfw:commentRss>
		<slash:comments>12</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 return of the u element</title>
		<link>http://html5doctor.com/u-element/</link>
		<comments>http://html5doctor.com/u-element/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 14:00:37 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Specification Changes]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[u]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3862</guid>
		<description><![CDATA[<p>The <code>&#60;u&#62;</code> element was deprecated in HTML 4 and non-conforming in HTML5, but a couple of use cases have seen it return from the dead. Are the use cases enough to persuade you that it’s a phoenix not a zombie?</p>]]></description>
			<content:encoded><![CDATA[<p>Presentational elements like <a href="http://html5doctor.com/i-b-em-strong-element/" title="The i, b, em, &amp; strong elements | HTML5 Doctor"><code>&lt;i&gt;</code>, <code>&lt;b&gt;</code></a>, <a href="http://html5doctor.com/small-hr-element/" title="The small &amp; hr elements | HTML5 Doctor"><code>&lt;small&gt;</code> and <code>&lt;hr&gt;</code></a> have been redefined in HTML5 with semantic meanings, or, in a couple of cases, made non-conforming. The <code>&lt;u&gt;</code> element had been in the non-conforming camp, but a couple of semantic use cases led it back into the fold. While most of us will never need it (and some will jeer), on the odd occasion, it might be just the element you need.</p>

<p>Before HTML5, <code>&lt;u&gt;</code> was solely for applying a presentational style of <em>underlining</em> to text. <a href="http://www.w3.org/TR/html401/present/graphics.html#h-15.2" title="Alignment, font styles, and horizontal rules in HTML documents">HTML 4 discouraged “font-style” or presentational elements</a>, and even <a href="http://www.w3.org/TR/html401/appendix/changes.html#idx-deprecated" title="HTML 4 Changes">deprecated <code>&lt;u&gt;</code></a>, advising us to use CSS instead. Even before this, <code>&lt;u&gt;</code> was frowned upon as underlines are the browser default for links, and making normal text look like links gives users a bad case of clicky-clicky frustration. <code>&lt;u&gt;</code> was initially non-conforming in HTML5.</p>

<p>There are, however, a couple of non-link places where text <em>is</em> traditionally underlined to convey meaning, as the HTML5 specification’s definition mentions:</p>

<blockquote>
<p>The <code>u</code> element represents a span of text with an unarticulated, though explicitly rendered, non-textual annotation, such as labeling the text as being a proper name in Chinese text (a Chinese proper name mark), or labeling the text as being misspelt.</p>
<footer>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/complete/text-level-semantics.html#the-u-element" title="4.6 Text-level semantics &#8212; Web Applications 1.0"><abbr title="">WHATWG</abbr> HTML5 specification</a></cite></footer>
</blockquote>

<p>Before we get to them, let’s quickly cover <em>an unarticulated, though explicitly rendered, non-textual annotation</em>. This means <q><code>&lt;u&gt;</code> is for when you are annotating something, but not explicitly saying what it is</q> (<cite><a href="http://krijnhoetmer.nl/irc-logs/whatwg/20110930#l-916" title="IRC logs: freenode / #whatwg / 20110930">WHATWG IRC</a></cite>, Ian Hickson) — the annotation’s meaning is implied by context.</p>

<section id="proper-name-mark">
<h2>Chinese proper name marks <a class="permalink" href="#proper-name-mark">#</a></h2>

<p>And what exactly are those you ask? I had to ask Wikipedia myself:</p>

<blockquote>
<p>In Chinese writing, a proper name mark (Simplified Chinese: <span lang="Hans">专名号</span>, <span lang="zh-Latn">zhuānmínghào</span>; Traditional Chinese: <span lang="Hant">專名號</span>) is an underline used to mark proper names, such as the names of people, places, dynasties, organizations. … This method of recognizing proper names in text is similar to the English use of a capital letter.</p>
<footer>— <cite><a href="http://en.wikipedia.org/wiki/Proper_name_mark" title="Proper name mark - Wikipedia, the free encyclopedia">Proper name mark</a></cite>, Wikipedia</footer>
</blockquote>

<p>Wikipedia gives the following example, which I’ve formatted using <code>&lt;u&gt;</code>:</p>

<figure id="pnm">
<style scoped>#pnm .pnm, #pnm .bnm {text-decoration: underline;}
#pnm .bnm {
  -moz-text-decoration-style: wavy;
  text-decoration-style: wavy;
}
#pnm p[lang="zh"] cite {font-style: normal;}</style>
<pre><code lang="zh">&lt;u class="pnm"&gt;屈原&lt;/u&gt;放逐，乃賦&lt;cite class="bnm"&gt;離騒&lt;/cite&gt;。&lt;u class="pnm"&gt;左丘&lt;/u&gt;失明，厥有&lt;cite class="bnm"&gt;國語&lt;/cite&gt;。（司馬遷 《&lt;cite&gt;報任安書&lt;/cite&gt;》）</code></pre>
<p lang="zh"><u class="pnm">屈原</u>放逐，乃賦<cite class="bnm">離騒</cite>。<u class="pnm">左丘</u>失明，厥有<cite class="bnm">國語</cite>。（司馬遷 《<cite>報任安書</cite>》）</p>
<!-- The source doesn’t use proper and book name marks for the citation because modern usage is only to use guillemets for the title — only the quoted text is classical -->
<p><mark lang="zh">Qu Yuan</mark> was exiled, and thus composed the <mark lang="zh"><cite>Li Sao</cite></mark>. <mark lang="zh">Zuo Qiu</mark> lost his sight, hence there is the <mark lang="zh"><cite>Guo Yu</cite></mark>. (<span lang="zh">Sima Qian</span>, “<cite>Letter to <span lang="zh">Ren'an</span></cite>”)</p>
<figcaption>Using <code>&lt;u&gt;</code> for Chinese proper name marks where appropriate</figcaption>
</figure>

<p>If you’re using Firefox 6+ you’ll also see the appropriate wavy underline for a Chinese book name mark on the quote’s source, courtesy of CSS3’s <code>text-decoration-style: wavy;</code>. I’ve used <code>&lt;cite&gt;</code> for book name marks as it’s more appropriate than <code>&lt;u&gt;</code>. You can find out more about <code>wavy</code> in <a href="http://dev.w3.org/csswg/css3-text/Overview.html#decoration" title="CSS Text Level 3">CSS Text Level 3</a>.</p>

<!-- /#proper-name-mark --></section>

<section id="spell-check">
<h2>Using <code>&lt;u&gt;</code> for spell-checking feedback <a class="permalink" href="#spell-check">#</a></h2>

<p>While you’re probably not marking up classical Chinese prose, a more familiar use case is for a spell-checker to indicate incorrect text. The default formatting in word processors is typically a red underline for spelling errors, and a green underline for grammatical errors:</p>

<figure id="spelling">
<style scoped>#spelling .spelling-error {
  text-decoration: none;
  border-bottom: 1px dashed red;
}
#spelling .grammatical-error {
  text-decoration: none;
  border-bottom: 1px dashed green;
}</style>
<pre><code>.spelling-error {
  text-decoration: none;
  border-bottom: 1px dashed red;
}
.grammatical-error {
  text-decoration: none;
  border-bottom: 1px dashed green;
}
&lt;p&gt;hello doctor i am having a huge body &lt;u class="spelling-error"&gt;oder&lt;/u&gt; &lt;u class="grammatical-error"&gt;it is smell really bad&lt;/u&gt;&lt;/p&gt;</code></pre>
<p>hello doctor i am having a huge body <u class="spelling-error">oder</u> <u class="grammatical-error">it is smell really bad</u></p>
<figcaption>Using <code>&lt;u&gt;</code> for annotating spell checker feedback</figcaption>
</figure>

<p>While we’ve turned off the default <code>text-decoration</code> style, <code>&lt;u&gt;</code> will back us up if CSS is disabled, and potentially provide more information for assistive technology. After all, if it’s semantic it should be in HTML, not CSS.</p>

<p>Some word processors use wavy underlines. This CSS would have the same effect in a supporting browser:</p>

<pre><code>.spelling-error {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: red;
}
.grammatical-error {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: green;
}</code></pre>

<p>Or, using <code>text-decoration</code> as a shorthand property, and adding a default declaration for non-supporting browsers:</p>

<pre><code>.spelling-error {
  text-decoration: underline; /* for backwards compatibility */
  text-decoration: underline wavy red;
}
.grammatical-error {
  text-decoration: underline; /* for backwards compatibility */
  text-decoration: underline wavy green;
}</code></pre>

<p>Again, you can read more about the upgraded <code>text-decoration</code> properties in <a href="http://dev.w3.org/csswg/css3-text/Overview.html#decoration" title="CSS Text Level 3">CSS Text Level 3</a>.</p>

<!-- /#spell-check --></section>

<section id="family-names">
<h2>Using <code>&lt;u&gt;</code> for indicating family names <a class="permalink" href="#family-names">#</a></h2>

<p>Another use for <code>&lt;u&gt;</code> is to annotate a family name when this might be confusing — Chinese, Japanese, Korean and Vietnamese (among others) all traditionally write names in a different order than the western-centric “given-name family-name”. While applying a blanket western ordering is fairly common (especially when publishing in English), it’s good form to use culturally appropriate ordering. If the audience might misunderstand, the family name can be underlined, capitalised, or otherwise annotated to make the name order explicit. For example, the <abbr title="Central Intelligence Agency">CIA</abbr>’s World Fact Book capitalises the family name:</p>

<blockquote>
<p>After World War II, the Communists under <mark>MAO Zedong</mark> established an autocratic socialist system …</p>
<footer>— <cite><a href="https://www.cia.gov/library/publications/the-world-factbook/geos/ch.html">The World Factbook</a></cite>, <abbr title="Central Intelligence Agency">CIA</abbr></footer>
</blockquote>

<p>This ties in nicely with <a href="http://html5doctor.com/microformats/#hcard" title="Extending HTML5 — Microformats | HTML5 Doctor">the hCard microformat</a>, as the “implied <code>n</code> optimisation” doesn’t work with these non-western ordered names, and we need a wrapper element to indicate each part of the name anyhow.</p>

<figure id="family-name1">
<style scoped>#family-name1 .family-name {text-decoration: underline;}</style>
<pre><code>&lt;style&gt;
  .family-name {text-decoration: underline;}
&lt;/style&gt;
&lt;p&gt;
  &lt;span class="vcard" lang="ja-latn"&gt;
    &lt;span class="fn n"&gt;
      &lt;u class="family-name"&gt;Son&lt;/u&gt; &lt;span class="given-name"&gt;Goku&lt;/span&gt;
    &lt;/span&gt;
  &lt;/span&gt;
   is the main protagonist in 
  &lt;span class="vcard" lang="ja-latn"&gt;
    &lt;span class="fn n"&gt;
      &lt;span class="given-name"&gt;Akira&lt;/span&gt; &lt;u class="family-name"&gt;Toriyama&lt;/u&gt;
    &lt;/span&gt;
  &lt;/span&gt;’s &lt;i lang="ja-latn"&gt;manga&lt;/i&gt; “Dragon Ball”.
&lt;/p&gt;</code></pre>
<p><span class="vcard" lang="ja-latn"><span class="fn n"><u class="family-name">Son</u> <span class="given-name">Goku</span></span></span> is the main protagonist in <span class="vcard" lang="ja-latn"><span class="fn n"><span class="given-name">Akira</span> <u class="family-name">Toriyama</u></span></span>’s <i lang="ja-latn">manga</i> “Dragon Ball”.</p>
<figcaption>Using <code>&lt;u&gt;</code> to indicate the family name in non-western names via underlining</figcaption>
</figure>

<p>Of course you can then change the style via CSS, for example</p>

<figure id="family-name2">
<style scoped>#family-name2 .family-name {
  text-decoration: none;
  text-transform: uppercase;
}</style>
<pre><code>.family-name {
  text-decoration: none;
  text-transform: uppercase;
}
</code></pre>
<p><span class="vcard" lang="ja-latn"><span class="fn n"><u class="family-name">Son</u> <span class="given-name">Goku</span></span></span> is the main protagonist in <span class="vcard" lang="ja-latn"><span class="fn n"><span class="given-name">Akira</span> <u class="family-name">Toriyama</u></span></span>’s <i lang="ja-latn">manga</i> “Dragon Ball”.</p>
<figcaption>Using <code>&lt;u&gt;</code> to indicate the family name in non-western names via capitalisation</figcaption>
</figure>

<p>The benefit of using <code>&lt;u&gt;</code> for this is the family name will be indicated even when CSS is disabled, ensuring the annotation isn’t lost. Assistive technology may also be able to inform the user of this in the future.</p>

<!-- /#family-names --></section>

<section id="do-we-need-u">
<h2>But do we need <code>&lt;u&gt;</code>? <a class="permalink" href="#do-we-need-u">#</a></h2>

<p>A lot of people bitten by the web standardista bug have somewhat of an allergic reaction to ex-presentational elements in HTML5, after influential articles like Tantek Çelik’s “<a href="http://tantek.com/log/2002/10.html#L20021022t1432" title="tantek/log/2002/10"><code>&lt;b&gt;</code>ed and <code>&lt;br&gt;</code>eakfast markup</a>”. Given <code>&lt;u&gt;</code>’s ignoble past, I expect the reaction to its return will also lead to some poo-pooing. As we already mentioned, however, <em>if it imparts meaning, it should be in HTML</em>. These use cases involve semantic meaning, and even without assistive technology support, <code>&lt;u&gt;</code> conveys some meaning to sighted users via the browser-default style <code>text-decoration: underline;</code>.</p>

<p>Regardless of whether an element is deprecated (HTML 4, XHTML 1)  or non-conforming (HTML5) or just plain uncool, browser makers still have to support it for backward compatibility with all those awesome web pages from the days when <code>&lt;blink&gt;</code> was hawt. Because of this, if there’s a semantic use case for an ex-presentational element, it’s definitely better to reform it rather than minting a new element with no backward compatibility. You might think <code>&lt;mark&gt;</code> sounds pretty similar, but the default browser styling would be completely wrong for proper name marks, and <a href="http://krijnhoetmer.nl/irc-logs/whatwg/20110930#l-890" title="IRC logs: freenode / #whatwg / 20110930">semantically less appropriate for spelling errors</a> too.</p>

<p>As Ian Hickson explains:</p>

<blockquote>
<p>The presentational markup that was <code>&lt;u&gt;</code>, <code>&lt;i&gt;</code>, <code>&lt;b&gt;</code>, <code>&lt;font&gt;</code>, <code>&lt;small&gt;</code>, etc, is gone. However, there are certain use cases that did not yet have elements yet were important enough to warrant us supporting them. By reusing existing elements, we are able to support them without having to wait for new elements to be implemented. By doing so in a way that closely matches how those elements were actually used in practice (at least to the same extent as other elements have been correctly used in practice) we can not only have older UAs support these new elements automatically, but we can do so in a way that does not introduce an undue volume of invalid pages.</p>
<footer>— <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-July/032715.html" title="[whatwg] sic element">WHATWG email list</a>, Ian Hickson</footer>
</blockquote>

<!-- /#do-we-need-u --></section>

<section id="conclusion">
<h2>Conclusion</h2>

<p>Given the potential to confuse underlined text with links, using <code>text-decoration: underline;</code> on anything other than <code>&lt;a&gt;</code> is bad pretty much all the time. <strong>Generally <code>&lt;u&gt;</code> is not the element you’re looking for</strong>, even for Chinese book name marks (<code>&lt;cite&gt;</code> would be more appropriate). <em>However</em>, for at least these three use cases, it’s good to have a semantic option, something better than <code>&lt;span&gt;</code>.</p>

<p>So…in a hypothetical world where you did need to code for one of these situations, would you use <code>&lt;u&gt;</code> or something else like <code>&lt;span&gt;</code>? Let us know in the comments!</p>

<!-- /#conclusion --></section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/ruby-rt-rp-element/" rel="bookmark" class="crp_title">The ruby element and her hawt friends, rt and rp</a></li><li><a href="http://html5doctor.com/html-5-reset-stylesheet/" rel="bookmark" class="crp_title">HTML5 Reset Stylesheet</a></li><li><a href="http://html5doctor.com/i-b-em-strong-element/" rel="bookmark" class="crp_title">The i, b, em, &amp; strong elements</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><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></ul></div><p><a href="http://html5doctor.com/u-element/" rel="bookmark">The return of the u element</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 25, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/u-element/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Dive into HTML5… on HTML5 Doctor</title>
		<link>http://html5doctor.com/dive-into-html5-doctor/</link>
		<comments>http://html5doctor.com/dive-into-html5-doctor/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 12:50:57 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[diveintohtml5]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[Mark Pilgrim]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3886</guid>
		<description><![CDATA[<p>We were surprised and saddened when Mark Pilgrim decided to retire from the internet and take his writing, including “Dive into HTML5” with him. However the interwebs have your back. We’re adding a mirror of the book here to add to the growing list, and plan to help keep it updated. So long Mark, and thanks for all the &#60;>!</p>]]></description>
			<content:encoded><![CDATA[<p>Last week, we were surprised and saddened when Mark Pilgrim, long time educator, raconteur, and writer of note, decided to retire from the internet. Unfortunately, he also decided to <a href="http://meyerweb.com/eric/thoughts/2011/10/04/searching-for-mark-pilgrim/" title="“Embracing HTTP error code 410 means embracing the impermanence of all things” Meyerweb: Searching For Mark Pilgrim"><code>410: gone</code> all of his writing</a>, including <cite>Dive into HTML5</cite>.</p>

<p>Mark provided this book <em>for free</em> on the web (under a <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons — Attribution 3.0 Unported — CC BY 3.0">Creative Commons By 3.0 license</a>), in addition to a published, for-sale version entitled <a href="http://www.amazon.com/dp/0596806027"><cite>HTML5: Up and Running</cite> from O’Reilly</a>. This is a very unusual setup, but one we’ve collectively benefitted from. Many HTML5 Doctor articles feature links to this book, and the sudden loss of this valuable resource was a little shocking.</p>

<p>The interwebs soon mobilised, however, and now there are several copies of this book, including:</p>

<ul>
<li><a href="http://diveintohtml5.info">diveintohtml5.info</a> and <a href="http://diveinto.org">diveinto.org</a> (<a href="https://github.com/jonathantneal/diveintohtml5">GitHub</a>)</li>
<li><a href="http://mislav.uniqpath.com/diveintohtml5/" title="Dive Into HTML5">mislav.uniqpath.com</a> (<a href="https://github.com/mislav/diveintohtml5">GitHub</a>)</li>
<li><a href="http://diveintohtml5.ep.io">diveintohtml5.ep.io</a> (<a href="https://github.com/diveintomark/diveintohtml5">GitHub</a>)</li>
<li>A bunch of forks, site archives, and PDFs on GitHub and elsewhere, such as <a href="http://mislav.uniqpath.com/2011/10/dive-into-html5/" title="Dive into HTML5: In memory of Mark Pilgrim">Mislav Marohnić’s beautiful PDF eBook</a></li>
</ul>

<p>There are also several partial translations, including:</p>

<ul>
<li>Chinese: <a href="http://diveintohtml5.com">diveintohtml5.com</a> (<a href="https://github.com/diveintohtml5-zh-cn/diveintohtml5.zh-cn">GitHub</a>)</li>
<li>Japanese: <a href="https://github.com/myakura/dih5ja">GitHub</a> and <a href="http://hail2u.net/documents/diveintohtml5-semantics.html">hail2u.net</a></li>
<li>Czech: <a href="http://kniha.html5.cz/">kniha.html5.cz</a> (<a href="https://github.com/met/diveintohtml5">GitHub</a>)</li>
<li>French: <a href="http://www.jeremyselier.com/diveintohtml5/">jeremyselier.com</a></li>
</ul>

<p><em>(Please leave a comment if you know of any others!)</em></p>

<p>Jonathan Neal is coordinating diveintohtml5.info and diveinto.org, and has added the following to the book’s title page:</p>

<blockquote>
<p>Mark Pilgrim has stopped maintaining this project, and we want it to continue. We’re not just patching broken links and updating APIs. We plan to actively maintain it; refreshing, updating, and reflecting the relevant and current state of HTML5, just as it had been during Mark’s tenure.</p>
<footer>— <cite><a href="http://diveintohtml5.info/" title="Dive Into HTML5">diveintohtml5.info</a></cite>, <a href="https://twitter.com/jon_neal">Jonathan Neal</a></footer>
</blockquote>

<p>We doctors feel the same way and plan to help keep the book updated. To that end, we’ve set up a mirror at <a href="http://diveinto.html5doctor.com" title="Dive Into HTML5"><strong>diveinto.html5doctor.com</strong></a>, and we’ll be experimenting with using <a href="https://github.com/html5doctor/diveintohtml5">GitHub</a> to contribute.</p>

<p>We’d like to publicly thank Mark Pilgrim for both writing this wonderful reference on HTML5 (and all his other writing over the years), and for making <cite>Dive into HTML5</cite> available under a CC-By license that makes it possible for us to mirror it here. We’re interested to see where this brave new world of distributed community editing collectively takes us, and <a href="https://github.com/html5doctor/diveintohtml5">we invite you to pitch in</a>.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/review-html5-designing-rich-internet-applications/" rel="bookmark" class="crp_title">Review: HTML5 Designing Rich Internet Applications</a></li><li><a href="http://html5doctor.com/html5-for-web-developers/" rel="bookmark" class="crp_title">HTML5 for Web Developers</a></li><li><a href="http://html5doctor.com/the-scoped-attribute/" rel="bookmark" class="crp_title">The scoped attribute</a></li><li><a href="http://html5doctor.com/server-sent-events/" rel="bookmark" class="crp_title">Server-Sent Events</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></ul></div><p><a href="http://html5doctor.com/dive-into-html5-doctor/" rel="bookmark">Dive into HTML5… on HTML5 Doctor</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 17, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/dive-into-html5-doctor/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Quoting and citing with &lt;blockquote&gt;, &lt;q&gt;, &lt;cite&gt;, and the cite attribute</title>
		<link>http://html5doctor.com/blockquote-q-cite/</link>
		<comments>http://html5doctor.com/blockquote-q-cite/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 13:30:21 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[blockquote]]></category>
		<category><![CDATA[cite]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[q]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3373</guid>
		<description><![CDATA[<p>Given HTML’s roots in the academic world, it should be no surprise that quoting is well-accomodated in the elements blockquote and q, with their optional cite attribute. In addition, there’s the cite element, which over the last nine years went from ‘semantic orphan element made good’ to one of the more contentious elements in HTML5. Let’s power up the endoscope and examine the scarring, starting with blockquote.</p>]]></description>
			<content:encoded><![CDATA[<p>Given HTML’s roots in the academic world, it should be no surprise that quoting is well-accommodated in the elements <code>&lt;blockquote&gt;</code> and <code>&lt;q&gt;</code>, with their optional <code>cite</code> attribute. In addition, there’s the <code>&lt;cite&gt;</code> element, which over the last nine years went from ‘semantic orphan element made good’ to one of the more contentious elements in HTML5. Let’s power up the endoscope and examine the scarring, starting with <code>&lt;blockquote&gt;</code>.</p>

<section id="blockquote">
<h2>Quoting with <code>&lt;blockquote&gt;</code> <a class="permalink" href="#blockquote">#</a></h2>

<p>We’ve become pretty familiar with <code>&lt;blockquote&gt;</code> here, as most of our articles feature excerpts from the HTML5 specification. Look, here’s one right now:</p>

<blockquote>
<p>The <code>blockquote</code> element represents a section that is quoted from another source.</p>
<footer>— <cite><a href="http://dev.w3.org/html5/spec/grouping-content.html#the-blockquote-element" title="4.5 Grouping content &#8212; HTML5">W3C HTML5 specification</a></cite></footer>
</blockquote>

<p>Easy peasy, right? Nothing has really changed. Remember that as <code>&lt;blockquote&gt;</code> is a ‘block-level element’ (<em>flow content</em>) we can put most anything in it, including headers, images and tables, in addition to the usual paragraphs of text.</p>

<p>There are a couple of slight differences in HTML5 though. <code>&lt;blockquote&gt;</code> is a <em>sectioning root</em>, meaning that any <code>&lt;h1&gt;</code>-<code>&lt;h6&gt;</code> elements it contains don’t become part of the document’s outline. Also, adding a single paragraph of text with no enclosing <code>&lt;p&gt;</code> tags is now completely kosher.</p>

<p>Here are some simple <code>&lt;blockquote&gt;</code> examples (apologies for the fake content):</p>

<figure>
<pre><code>&lt;blockquote&gt;This is a short block quote — look Ma, no paragraph tags!&lt;/blockquote&gt;</code></pre>
<blockquote>This is a short block quote — look Ma, no paragraph tags!</blockquote>
</figure>

<figure>
<pre><code>&lt;blockquote&gt;&lt;p&gt;This is a longer block quote.&lt;/p&gt;
  &lt;p&gt;It uses paragraph elements.&lt;/p&gt;
&lt;/blockquote&gt;</code></pre>
<blockquote><p>This is a longer block quote.</p>
<p>It uses paragraph elements.</p></blockquote>
</figure>

<figure>
<pre><code>&lt;blockquote&gt;&lt;h1&gt;OMG a heading!&lt;/h1&gt;
  &lt;ul&gt;&lt;li&gt;Block quotes can contain more than just paragraphs…&lt;/li&gt;&lt;/ul&gt;
&lt;/blockquote&gt;</code></pre>
<blockquote><h1>OMG a heading!</h1>
  <ul><li>Block quotes can contain more than just paragraphs…</li></ul>
</blockquote>
</figure>

<p>Historically, adding the source of a <code>&lt;blockquote&gt;</code> was a semantic conundrum. If you add it as content of the <code>&lt;blockquote&gt;</code>, then semantically it would become part of the quote, right? <code>&lt;blockquote&gt;</code> (and <code>&lt;q&gt;</code>) have a <code>cite</code> attribute for the URL of the quote’s source, to provide context. That’s hidden data, however, and despite <a href="http://www.holovaty.com/writing/176/">the potential for exposing the <code>cite</code> attribute via CSS and/or JS</a>, that’s not as useful as a visible link.</p>

<div id="change-2011-07-11" class="callout warning-block">
<aside class="sidenote"><p><em>Non-conforming</em> means that while it will validate, adding a <code>&lt;footer&gt;</code> that isn’t in the quote’s source goes against the spec</p></aside>
<ins datetime="2011-07-11T14:48:12+0900">
<p><em><time>2011-07-11</time></em> It seems our long-running convention at HTML5 Doctor of using <code>&lt;footer&gt;</code> for attribution inside a <code>&lt;blockquote&gt;</code> is actually <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=13082" title="Bug 13082"><em>non-conforming</em></a>. However the phrase in the spec that prevents it also prevents other common block quoting patterns, so the spec will probably change. Read my article <a href="http://oli.jp/2011/blockquote/" title="Blockquote problems and solutions ❧ Oli.jp (@boblet)"><code>&lt;blockquote&gt;</code> problems and solutions</a>, and submit <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-July/032334.html" title="[whatwg] The blockquote element spec vs common quoting practices">feedback via the WHATWG email list</a>, the comments here or to be via <a href="http://twitter.com/boblet">Twitter (@boblet)</a> — your feedback will influence <em>how</em> the spec changes!</ins></p>
<p>I’ll <a href="#updates">update this article</a> after the change, but until then be aware <strong><code>&lt;footer&gt;</code> for attribution in a <code>&lt;blockquote&gt;</code> isn’t strictly valid</strong>, and may not be in the future either. The spec currently recommends including attribution in content surrounding the <code>&lt;blockquote&gt;</code>.</p>
</div>

<p id="change-2012-02-14" class="callout changed-block"><em><time datetime="2012-02-14T15:20:27+13:00">2012-02-14</time></em> <a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-February/034822.html">Hixie has given his feedback on my email</a>, and it seems like our <code>&lt;footer></code> citations are still invalid. The official recommendation is to put the blockquote in a figure and add attribution in <code>&lt;figcaption></code>. Read the whole thread as there are some interesting comments. I’ll wait for the dust to settle a little yet…</p>

<div class="faint">
<style scoped>
.faint {color: #777;}
</style>
<p>HTML5 comes to our rescue with the <code>&lt;footer&gt;</code> element, allowing us to add semantically separate information <em>about</em> the quote. For example:</p>

<figure>
<pre><code>&lt;blockquote&gt;
  &lt;p&gt;You know the golden rule, don’t you boy? Those who have the gold make the rules.&lt;/p&gt;
  &lt;footer&gt;— Crazy hunch-backed old guy from the movie Aladdin&lt;/footer&gt;
&lt;/blockquote&gt;
</code></pre>
<blockquote>
  <p>You know the golden rule, don’t you boy? Those who have the gold make the rules.</p>
  <footer>— Crazy hunch-backed old guy from the movie Aladdin</footer>
</blockquote>
</figure>

<p>Because of this semantically sound way to show the quote’s source, <ins datetime="2011-07-11T14:34:56+0900">if you’re going to add a <code>cite</code> attribute on <code>&lt;blockquote&gt;</code>, only do so <em>in addition</em> to visible attribution</ins>.</p>

<figure>
<pre><code>&lt;blockquote cite="http://www.imdb.com/character/ch0000672/quotes"&gt;
&lt;p&gt;You know the golden rule, don’t you boy? Those who have the gold make the rules.&lt;/p&gt;
&lt;footer&gt;— &lt;a href="http://www.imdb.com/character/ch0000672/quotes"&gt;Crazy hunch-backed old guy in Aladdin&lt;/a&gt;&lt;/footer&gt;
&lt;/blockquote&gt;
</code></pre>
<blockquote>
<p>You’ve heard of the golden rule, haven’t you? Whoever has the gold makes the rules.</p>
<footer>— <a href="http://www.imdb.com/character/ch0000672/quotes">Crazy hunch-backed old guy in Aladdin</a></footer>
</blockquote>
</figure>
</div>

<p>Even then, the <code>cite</code> attribute is probably only worth it if you can automate it (or you're just crazy OCD ;). We’ll return to <code>&lt;blockquote&gt;</code> in a bit, but let’s first probe into <code>&lt;q&gt;</code>.</p>

<!-- /#blockquote --></section>

<section id="q">
<h2>Inline quotations with <code>&lt;q&gt;</code> <a class="permalink" href="#q">#</a></h2>

<p><code>&lt;q&gt;</code> is for quoting something inline within a section of prose:</p>

<blockquote>
<p>The <code>q</code> element represents some phrasing content quoted from another source.</p>
<footer>— <cite><a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-q-element" title="4.6 Text-level semantics &#8212; HTML5">W3C HTML5 specification</a></cite></footer>
</blockquote>

<p>This means we can’t use <code>&lt;q&gt;</code> for sarcasm or other non-quotation uses of quote marks (“”). In those cases, add punctuation manually.</p>
  
<p>The spec continues:</p>

<blockquote>
<p>Quotation punctuation (such as quotation marks) that is quoting the contents of the element must not appear immediately before, after, or inside <code>q</code> elements; they will be inserted into the rendering by the user agent.</p>
<footer>— <cite><a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-q-element" title="4.6 Text-level semantics &#8212; HTML5">W3C HTML5 specification</a></cite></footer>
</blockquote>

<p>As with <code>&lt;blockquote&gt;</code>, you can also add a <code>cite</code> attribute with a URL for the quotation’s source (subject to the above caveats against hidden data). If you’re not using these extra features though, it’s a toss-up as to whether <code>&lt;q&gt;</code> is any better than just adding punctuation characters like “” as you type.</p>

<p>Okay, let’s see some specimens:</p>

<figure>
  <figcaption>Nested quotations:</figcaption>
<pre><code>&lt;p&gt;Luke continued, &lt;q&gt;And then she called him a &lt;q&gt;scruffy-looking nerf-herder&lt;/q&gt;! I think I’ve got a chance!&lt;/q&gt; The poor naive fool…&lt;/p&gt;
</code></pre>
<p>Luke continued, <q>And then she called him a <q>scruffy-looking nerf-herder</q>! I think I’ve got a chance!</q> The poor naive fool…</p>
</figure>

<div class="lang-example">
<style scoped>
.lang-example :lang(ja) > q {quotes: '「' '」' '『' '』';}
.lang-example :lang(ja-latn) > q {quotes: '“' '”' '‘' '’';}
</style>
<figure>
<figcaption>Language-appropriate quotations <ins datetime="2011-06-29T13:32:48+09:00">(example updated, thanks <a href="#comment-15413">Zev</a>, <a href="#comment-15433">Bertil</a>, &amp; <a href="#comment-25155">Janus</a>)</ins>:</figcaption>
<aside class="sidenote"><p><ins datetime="2011-06-29T13:32:48+09:00">For more information see <a href="#foreign-languages">styling foreign quotations</a></ins></p></aside>
<pre><code>&lt;ul&gt;
&lt;li lang="ja"&gt;彼女は&lt;q&gt;日本語に猫は『にゃん』と鳴く&lt;/q&gt;と言った。&lt;/li&gt;
&lt;li&gt;&lt;i lang="ja-latn"&gt;Kanojo wa &lt;q&gt;Nihongo ni neko wa ‘nyan’ to naku&lt;/q&gt; to itta.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;She said &lt;q&gt;In Japanese cats say &lt;i lang="ja-latn"&gt;nyan&lt;/i&gt;&lt;/q&gt;.&lt;/li&gt;
&lt;/ul&gt;
</code></pre>
<ul class="semantic-list">
<li lang="ja">彼女は<q>猫は『にゃん』と鳴く</q>と言った。</li>
<li><i lang="ja-latn">Kanojo wa <q>Nihongo ni neko wa ‘nyan’ to naku</q> to itta.</i></li>
<li>She said <q>In Japanese cats say <i lang="ja-latn">nyan</i></q>.</li>
</ul>
</figure>
</div>
<figure>
<figcaption>A quotation using the cite attribute. Note that I’ve also included the <code>cite</code> attribute’s link in content so it’s accessible:</figcaption>
<pre><code>&lt;p&gt;&lt;a href="http://www.imdb.com/character/ch0000672/quotes"&gt;The Aladdin character Jafar&lt;/a&gt; presents an eloquent treatise on the recent global economic meltdown when he states &lt;q cite="http://www.imdb.com/character/ch0000672/quotes"&gt;You know the golden rule, don’t you boy? Those who have the gold make the rules.&lt;/q&gt;&lt;/p&gt;</code></pre>
<p><a href="http://www.imdb.com/character/ch0000672/quotes" title="Jafar (Character) - Quotes">The Aladdin character Jafar</a> presents an eloquent treatise on the recent global economic meltdown when he states <q cite="http://www.imdb.com/character/ch0000672/quotes">You know the golden rule, don’t you boy? Those who have the gold make the rules.</q></p>
</figure>

<p>Let’s examine how to style these elements next.</p>

<!-- /#q --></section>

<section id="styling">
<h2>Styling <code>&lt;q&gt;</code> and <code>&lt;blockquote&gt;</code> <a class="permalink" href="#styling">#</a></h2>

<p>Historically, browser support has been patchy for controlling the punctuation used by <code>&lt;q&gt;</code>. Things have settled down now, so we can define nested, language-specific and even author-defined punctuation via CSS.</p>

<table id="quotes-support" class="browser-support wider">
<caption>Browser support for styling quotes</caption>
<thead>
<tr>
  <th scope="col"></th>
  <th scope="col"><abbr title="Internet Explorer">IE</abbr></th>
  <th scope="col">Firefox</th>
  <th scope="col">Safari</th>
  <th scope="col">Chrome</th>
  <th scope="col">Opera</th>
</tr>
</thead>
<tbody>
<tr>
  <th scope="row">Default <code>&lt;q&gt;</code> punctuation<a href="#quotes-1">¹</a></th>
  <td>8.0 “” ‘’</td>
  <td>1.5 “” ‘’</td>
  <td>2.0 ""<br />
    4.0? "" ''</td>
  <td>1.0? "" ''</td>
  <td>4.0 “” ‘’</td>
</tr>
<tr>
  <th scope="row"><code>quotes</code> with Unicode escapes</th>
  <td>8.0</td>
  <td>1.5</td>
  <td>5.1<a href="#quotes-2">²</a></td>
  <td>11.0<a href="#quotes-2">²</a></td>
  <td class="warning">4.0<a href="#quotes-3">³</a></td>
</tr>
<tr>
  <th scope="row"><code>quotes</code> with glyphs</th>
  <td>8.0</td>
  <td>1.5</td>
  <td>5.1<a href="#quotes-2">²</a></td>
  <td>11.0<a href="#quotes-2">²</a></td>
  <td class="warning">4.0<a href="#quotes-3">³</a></td>
</tr>
</tbody>
</table>

<ol class="key">
<li id="quotes-1">Default <code>&lt;q&gt;</code> support requires on <code>:before</code> and <code>:after</code></li>
<li id="quotes-2">Webkit support has been weak, with "" and '' hard-coded until Safari 5.1 and Chrome 11. Ref: WebKit bugs <a href="https://bugs.webkit.org/show_bug.cgi?id=6503">6503 (fixed)</a> and <a href="https://bugs.webkit.org/show_bug.cgi?id=3234">3234 (new)</a>.</li>
<li id="quotes-3">Opera is buggy if you nest <code>&lt;q&gt;</code> to a greater depth than quote pairs in your <code>quotes</code> property (<a href="http://jsbin.com/ehevof">test case</a>)</li>
</ol>

<p>“Correct” punctuation is an intricate topic and <a href="http://en.wikipedia.org/wiki/Non-English_usage_of_quotation_marks" title="Non-English usage of quotation marks - Wikipedia, the free encyclopedia">varies depending on language</a>, but it generally involves these characters:</p>

<table id="punctuation-characters" class="widest">
<caption>Quote punctuation characters</caption>
<thead>
<tr>
<th scope="col">Glyph</th>
<th scope="col">Description</th>
<th scope="col">Unicode escape</th>
<th scope="col">Entity</th>
<th scope="col">Mac</th>
<th scope="col">Windows</th>
<th scope="col">Linux</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">“</th>
<td>Left double quotation mark</td>
<td>\201C</td>
<td><code>&amp;ldquo;</code></td>
<td><kbd>Option</kbd>-<kbd>[</kbd></td>
<td><kbd>Alt</kbd>+<kbd>0147</kbd></td>
<td><kbd>AltGr</kbd>+<kbd>V</kbd></td>
</tr>
<tr>
<th scope="row">”</th>
<td>Right double quotation mark</td>
<td>\201D</td>
<td><code>&amp;rdquo;</code></td>
<td><kbd>Option</kbd>-<kbd>Shift</kbd>-<kbd>[</kbd></td>
<td><kbd>Alt</kbd>+<kbd>0148</kbd></td>
<td><kbd>AltGr</kbd>+<kbd>B</kbd></td>
</tr>
<tr>
<th scope="row">‘</th>
<td>Left single quotation mark</td>
<td>\2018</td>
<td><code>&amp;lsquo;</code></td>
<td><kbd>Option</kbd>-<kbd>]</kbd></td>
<td><kbd>Alt</kbd>+<kbd>0145</kbd></td>
<td><kbd>AltGr</kbd>+<kbd>Shift</kbd>+<kbd>V</kbd></td>
</tr>
<tr>
<th scope="row">’</th>
<td>Right single quotation mark</td>
<td>\2019</td>
<td><code>&amp;rsquo;</code></td>
<td><kbd>Option</kbd>-<kbd>Shift</kbd>-<kbd>]</kbd></td>
<td><kbd>Alt</kbd>+<kbd>0146</kbd></td>
<td><kbd>AltGr</kbd>+<kbd>Shift</kbd>+<kbd>B</kbd></td>
</tr>
<tr>
<th scope="row">«</th>
<td>Double left-pointing angle quotation mark</td>
<td>\00AB</td>
<td><code>&amp;laquo;</code></td>
<td><kbd>Option</kbd>-<kbd>\</kbd></td>
<td><kbd>Alt</kbd>+<kbd>174</kbd></td>
<td><kbd>AltGr</kbd>+<kbd>[</kbd></td>
</tr>
<tr>
<th scope="row">»</th>
<td>Double right-pointing angle quotation mark</td>
<td>\00BB</td>
<td><code>&amp;raquo;</code></td>
<td><kbd>Option</kbd>-<kbd>Shift</kbd>-<kbd>\</kbd></td>
<td><kbd>Alt</kbd>+<kbd>175</kbd></td>
<td><kbd>AltGr</kbd>+<kbd>]</kbd></td>
</tr>
<tr>
<th scope="row">‹</th>
<td>Single left-pointing angle quotation mark</td>
<td>\2039</td>
<td><code>&amp;lsaquo;</code></td>
<td><kbd>Option</kbd>-<kbd>Shift</kbd>-<kbd>3</kbd></td>
<td><kbd>Alt</kbd>+<kbd>0139</kbd></td>
<td>-</td>
</tr>
<tr>
<th scope="row">›</th>
<td>Single right-pointing angle quotation mark</td>
<td>\203A</td>
<td><code>&amp;rsaquo;</code></td>
<td><kbd>Option</kbd>-<kbd>Shift</kbd>-<kbd>4</kbd></td>
<td><kbd>Alt</kbd>+<kbd>0155</kbd></td>
<td>-</td>
</tr>
<tr>
<th scope="row">„</th>
<td>Double low-9 quotation mark</td>
<td>\201E</td>
<td><code>&amp;bdquo;</code></td>
<td><kbd>Option</kbd>-<kbd>Shift</kbd>-<kbd>W</kbd></td>
<td><kbd>Alt</kbd>+<kbd>0132</kbd></td>
<td>-</td>
</tr>
<tr>
<th scope="row">‚</th>
<td>Single low-9 quotation mark</td>
<td>\201A</td>
<td><code>&amp;sbquo;</code></td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<th scope="row"> </th>
<td>Narrow no-break space</td>
<td>\202F</td>
<td><code>&amp;#8239;</code></td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
</tbody>
</table>

<aside class="sidenote"><p><a href="http://www.georgehernandez.com/h/xComputers/CharacterSets/Shortcuts.asp" title="Shortcuts by George Hernandez">More info on keyboard shortcuts for entering special characters</a>, including how to enter them via Unicode escape codes (hex input) on Macs &amp; PCs</p></aside>
<p class="note">If you’re using the <code>charset</code> UTF-8 (and you should be), we recommend you use the actual characters if possible, rather than the Unicode escapes in CSS or the entities in HTML. You can enter most of these using the keyboard — e.g. “ is <kbd>Opt</kbd>-<kbd>[</kbd> on Mac, <kbd>Alt</kbd> + <kbd>0147</kbd> on Windows, and <kbd>AltGr</kbd> + <kbd>V</kbd> on Linux. Avoid using ", ' or ` in place of “” and ‘’. The “narrow no-break space” is used inside French guillemets.</p>

<p>Most languages alternate between two kinds of punctuation as quotes are nested, such as “” and ‘’ in English. To specify nested quote pairs in CSS, we would write this:</p>

<pre><code>q {quotes: '“' '”' '‘' '’';} /* opening followed by closing quote pairs */
/* The equivalent using Unicode escapes:
  q {quotes: '\201C' '\201D' '\2018' '\2019';} */
q:before {content: open-quote;}
q:after {content: close-quote;}
</code></pre>

<p>Unfortunately, browsers use the last quote pair in the <code>quotes</code> property for more deeply nested quotations. <ins datetime="2011-06-29T00:17:49+09:00">In addition, Opera will use the wrong quote characters if you have more nested <code>&lt;q&gt;</code> than your <code>quotes</code> property defines quoting levels for (<a href="http://jsbin.com/ehevof">Opera quotes bug test case</a>).</ins> Make sure you have enough levels by repeating quote pairs as necessary:</p>

<pre><code>/* four levels of nested quotes */
q {quotes: '“' '”' '‘' '’' '“' '”' '‘' '’';}</code></pre>

<p>WebKit had "" and '' hard-coded in the browser stylesheet until Safari 5.1 and Chrome 11, which prevented <code>q:before {content: open-quote;}</code> and <code>q:after {content: close-quote;}</code> from working. <a href="http://yuilibrary.com/projects/yui3/ticket/2528708" title="#2528708 Issues with quotes : reset.css : YUI Library">The workaround is to define opening and closing punctuation manually</a>, then override with <code>open-quote</code> and <code>close-quote</code>. While it’s a little more involved, that’s why we use this CSS on HTML5 Doctor:</p>

<pre><code>/* for two levels of nested quotations */
q {quotes: '“' '”' '‘' '’';}
 /* extra content definitions for pre-2011 WebKit */
q:before {content: '“'; content: open-quote;}
q:after {content: '”'; content: close-quote;}
q q:before {content: '‘'; content: open-quote;}
q q:after {content: '’'; content: close-quote;}
  /* q in blockquote */
blockquote q:before {content: '‘'; content: open-quote;}
blockquote q:after {content: '’'; content: close-quote;}
blockquote q q:before {content: '“'; content: open-quote;}
blockquote q q:after {content: '”'; content: close-quote;}
  /* blockquote hanging opening quote */
blockquote:before {display: block; height: 0; content: "“"; margin-left: -.95em; font: italic 400%/1 Cochin,Georgia,"Times New Roman",serif; color: #999;}
</code></pre>

<p>A more traditional English <code>&lt;blockquote&gt;</code> style uses an opening quote character before each paragraph of the quotation and a closing quote character on the last paragraph. You can do that with this CSS, but you’ll need to use <code>&lt;p&gt;</code> for the <code>&lt;blockquote&gt;</code>’s content.</p>

<pre><code>/* alternative blockquote style */
blockquote {quotes: '“' '”';}
blockquote p:before {content: '“'; content: open-quote;}
blockquote p:after {content: ''; content: no-close-quote;}
blockquote p:last-child:after {content: '”'; content: close-quote;}
</code></pre>

<p id="foreign-languages">When quoting a foreign language, we use the quotation marks of the surrounding language, so a Japanese quote in an English sentence still uses English quotation marks:</p>

<p class="callout">All he knows how to say in Japanese is <del>「わかりません」</del> <ins>“わかりません”</ins> (I don’t understand).</p>

<p>If you’re dealing with multilingual content, you can specify the <code>quotes</code> property per-language:</p>

<pre><code>/* quotes for French, German (two kinds) and Japanese */
:lang(fr) > q {quotes: '«&#8239;' '&#8239;»' '“' '”';}
:lang(de) > q {quotes: '„' '“' '‚' '‘';}
:lang(de) > q {quotes: '»' '«' '›' '‹';} /* alternative style */
:lang(ja) > q {quotes: '「' '」' '『' '』';}
</code></pre>

<p>You can learn more about this CSS in the specification: <a href="http://dev.w3.org/csswg/css3-content/#specifying-quotes-with-the-quotes-proper" title="CSS Generated Content Module Level 3">CSS Generated Content Module Level 3</a>.</p>

<p>Okay, it’s time to put the rubber gloves on: <code>&lt;cite&gt;</code> is up next.</p>

<!-- /#styling --></section>

<section id="cite">
<h2>The rise and fall of <code>&lt;cite&gt;</code> <a class="permalink" href="#cite">#</a></h2>

<section id="cite-history">
<h3><code>&lt;cite&gt;</code>’s rise to stardom as the semantic super-element <a class="permalink" href="#cite-history">#</a></h3>

<p><a href="http://www.w3.org/MarkUp/html-spec/html-spec_5.html#SEC5.7.1.1">In HTML 2</a> <code>&lt;cite&gt;</code> was <q cite="http://www.w3.org/MarkUp/html-spec/html-spec_5.html#SEC5.7.1.1">used to indicate the title of a book or other citation</q>. But in HTML 3.2 and HTML 4.01, <code>&lt;cite&gt;</code> was more loosely defined as</p>

<blockquote><p>Cite: Contains a citation or a reference to other sources</p>
<footer>— <a href="http://www.w3.org/TR/html401/struct/text.html#edef-CITE" title="Paragraphs, Lines, and Phrases">HTML 4.01 specification</a></footer>
</blockquote>

<p>We can define “citation” as:</p>

<ul>
<li>a reference to authority or precedent,</li>
<li>a quotation that’s being cited, or</li>
<li>a mention of someone or something</li>
</ul>

<p>And “a reference to other sources” is even less specific [cue Jaws music]. The <a href="http://www.w3.org/TR/html401/struct/text.html#edef-CITE" title="Paragraphs, Lines, and Phrases">HTML 4.01 spec’s examples</a> were:</p>

<blockquote>
<p>As <code>&lt;CITE&gt;</code>Harry S. Truman<code>&lt;/CITE&gt;</code> said…</p>
<p>More information can be found in <code>&lt;CITE&gt;</code>[ISO-0000]<code>&lt;/CITE&gt;</code></p>
</blockquote>

<p>Sadly, an example of an academic-style citation wasn’t included.</p>

<p>Some standardistas enthusiastically adopted <code>&lt;cite&gt;</code> for its semantics, with the high point being <a href="http://diveintomark.org/archives/2002/12/27/pushing_the_envelope">Mark Pilgrim’s epic “Posts by citation”</a> (the results of which are now sadly 404’ed). In those heady days, <code>&lt;cite&gt;</code> was used in three main ways:</p>
<ol>
<li>
<p>To refer to a person, generally in connection with some reference or as the source of a quote:</p>
<pre class="callout warning-block"><code>&lt;!-- Not valid usage of cite in HTML5! --&gt;
&lt;p&gt;As &lt;cite&gt;George R. R. Martin&lt;/cite&gt; wrote in…&lt;/p&gt;</code></pre>
</li>
<li>
<p>To contain the title of a work being referred to or quoted from <ins datetime="2011-06-29T00:54:20+09:00">(what <code>&lt;cite&gt;</code> is now used for in HTML5 — <a href="http://html5doctor.com/blockquote-q-cite/#comment-15397">thanks Dylan</a>!)</ins>:</p>
<pre class="callout changed-block"><code>&lt;p&gt;&lt;cite&gt;A Game of Thrones&lt;/cite&gt;, by George R. R. Martin&lt;/p&gt;</code></pre>
</li>
<li>
<p>To contain a full academic-style citation (title plus author, and maybe bibliographic information):</p>
<pre class="callout warning-block"><code>&lt;!-- Not valid usage of cite in HTML5! --&gt;
&lt;p&gt;&lt;cite&gt;A Game of Thrones, by George R. R. Martin&lt;/cite&gt;&lt;/p&gt;</code></pre>
<ul>
<li>
<p>Historically this might also be marked up as:</p>
<pre class="callout warning-block"><code>&lt;!-- Not valid usage of cite in HTML5! --&gt;
&lt;p&gt;&lt;cite class="book-title"&gt;A Game of Thrones&lt;/cite&gt;, by &lt;cite class="author"&gt;George R. R. Martin&lt;/cite&gt;&lt;/p&gt;</code></pre>
</li>
<li>
<p>or <a href="http://en.wikipedia.org/wiki/Template:Quotation" title="Template:Quotation - Wikipedia, the free encyclopedia">as Wikipedia does</a> (with <code>&lt;cite&gt;</code> set to <code>font-style: normal;</code>):</p>
<pre class="callout warning-block"><code>&lt;!-- Not valid usage of cite in HTML5! --&gt;
&lt;p&gt;&lt;cite&gt;George R. R. Martin, &lt;i&gt;A Game of Thrones&lt;/i&gt;&lt;/cite&gt;&lt;/p&gt;</code></pre>
</li>
</ul>
</li>
</ol>

<p>“Wow, what an all-rounder!” I hear you say. “Is there anything <code>&lt;cite&gt;</code> can’t do?” The dirty secret of all this is the <code>&lt;cite&gt;</code> element has historically been semantics for the sake of semantics. So far, the only non-site-specific application of <code>&lt;cite&gt;</code> is browser default stylesheets, which format it with <code>font-style: italic;</code>. This is not a bad thing, as using <code>&lt;cite&gt;</code> consistently on your own site allows you to do all kinds of fun stuff (as Pilgrim demonstrated). But in the past, it’s been used to refer to <em>three related but quite different types of data:</em> titles, full citations, and names. This makes web-wide use, such as by a search engine, tricky.</p>

<!-- /#cite-history --></section>

<section id="cite-future">
<h3><code>&lt;cite&gt;</code> snorts too much semantics, checks into rehab <a class="permalink" href="#cite-future">#</a></h3>

<p>So, in HTML5 this semantic over-achiever has ended up with a more … prosaic definition:</p>

<blockquote>
<p>The cite element represents the title of a work (e.g. a book, a paper, an essay, a poem, a score, a song, a script, a film, a TV show, a game, a sculpture, a painting, a theatre production, a play, an opera, a musical, an exhibition, a legal case report, etc). This can be a work that is being quoted or referenced in detail (i.e. a citation), or it can just be a work that is mentioned in passing.</p>
<p><mark>A person's name is not the title of a work</mark> — even if people call that person a piece of work — <mark>and the element must therefore not be used to mark up people's names</mark></p>
<footer>— <cite><a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-cite-element" title="4.6 Text-level semantics &#8212; HTML5">W3C HTML5 specification</a></cite></footer>
</blockquote>

<aside class="sidenote"><p><q>A piece of work</q>, heh, that’s good</p></aside>

<p>This restriction has been somewhat … unpopular. Arguments for using <code>&lt;cite&gt;</code> for names (<a href="http://wiki.whatwg.org/wiki/Cite_element">now summarised on the <span class="caps">WHATWG</span> wiki</a>) were <a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2008-February/014008.html">addressed by Ian Hickson</a>, who decided that historical use wasn’t enough to justify the wooly definition. <a href="http://24ways.org/2009/incite-a-riot" title="24 ways: Incite A Riot">Jeremy Keith’s 24 Ways article “<cite>Incite A Riot</cite>”</a> called for civil disobedience and HTML 4.01-style <code>&lt;cite&gt;</code>-ing, but the HTML5 spec has not changed.</p>


<p>The in<code>&lt;cite&gt;</code>rs are irate that there are two use cases that <code>&lt;cite&gt;</code>’s new definition leaves semantically unfilled — to mark up speakers in a transcript or dialog, and to indicate the speaker or author of an inline quote (<code>&lt;q&gt;</code>). The <a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-cite-element" title="4.6 Text-level semantics &#8212; HTML5">HTML5 spec</a> adds semantic insult to injury by saying:</p>

<blockquote>
<p>In some cases, the <code>&lt;b&gt;</code> element might be appropriate for names; e.g. in a gossip article … In other cases, if an element is really needed, the <code>&lt;span&gt;</code> element can be used.</p>
</blockquote>

<p>By better defining <code>&lt;cite&gt;</code>, we increase the odds of getting usable data from it, though we now need different methods to cover these other uses. For now, it seems that these use cases aren’t specific enough to warrant new elements.</p>

<p>Note that <code>&lt;cite&gt;</code> was never a general-purpose element for marking up a person. The still-born HTML 3.0 did try to introduce the <code>&lt;person&gt;</code> element, but if you’ve ever used hCard to semantically mark up a person’s name, you’ll know that we’d need way more than just one element to do names justice. The <abbr title="plain old semantic HTML">POSH</abbr> way of marking up a name is to use hCard (in <a href="http://html5doctor.com/microformats/" title="Extending HTML5 — Microformats | HTML5 Doctor">microformats</a>, <a href="http://html5doctor.com/microdata" title="Extending HTML5 — Microdata | HTML5 Doctor">microdata</a> or RDFa), or just with a plain old link.</p>

<!-- /#cite-future --></section>

<section id="cite-examples">
<h3>Get ex<code>&lt;cite&gt;</code>d and quote stuff <a class="permalink" href="#cite-examples">#</a></h3>

<p>History and encouraging angry comments aside, let’s suture up and see some examples of HTML5-style <code>&lt;cite&gt;</code> action:</p>

<figure>
<figcaption>Use <code>&lt;cite&gt;</code> for a movie title:</figcaption>
<pre><code>&lt;p&gt;&lt;cite&gt;Aladdin&lt;/cite&gt; is a great movie, even after 73 viewings. Aren’t kids great?&lt;/p&gt;</code></pre>
<p><cite>Aladdin</cite> is a great movie, even after 73 viewings. Aren’t kids great?</p>
</figure>

<figure>
<figcaption>Even better, use <code>&lt;cite&gt;</code> with a link:</figcaption>
<pre><code>&lt;p&gt;&lt;cite&gt;&lt;a href="http://en.wikipedia.org/wiki/Aladdin_(1992_Disney_film)"&gt;Aladdin&lt;/a&gt;&lt;/cite&gt; is a great movie, even after 73 viewings. Aren’t kids great?&lt;/p&gt;</code></pre>
<p><cite><a href="http://en.wikipedia.org/wiki/Aladdin_(1992_Disney_film)">Aladdin</a></cite> is a great movie, even after 73 viewings. Aren’t kids great?</p>
</figure>

<figure>
<figcaption>Use <code>&lt;cite&gt;</code> for the title of a book (but not the author’s name):</figcaption>
<pre><code>&lt;p&gt;&lt;cite&gt;A Game of Thrones&lt;/cite&gt;, by George R. R. Martin&lt;/p&gt;</code></pre>
<p><cite>A Game of Thrones</cite>, by George R. R. Martin</p>
</figure>

<figure>
<figcaption>If you wanted to semantically indicate the author, you could use <a href="http://html5doctor.com/microformats/" title="Extending HTML5 — Microformats | HTML5 Doctor">microformats</a>, <a href="http://html5doctor.com/microdata" title="Extending HTML5 — Microdata | HTML5 Doctor">microdata</a> or RDFa:</figcaption>
<pre><code>&lt;p&gt;&lt;cite&gt;A Game of Thrones&lt;/cite&gt;, by &lt;span class="hcard"&gt;&lt;span class="fn n"&gt;&lt;span class="given-name"&gt;George&lt;/span&gt; &lt;span class="additional-name"&gt;R. R.&lt;/span&gt; &lt;span class="family-name"&gt;Martin&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</code></pre>
<p><cite>A Game of Thrones</cite>, by <span class="hcard"><span class="fn n"><span class="given-name">George</span> <span class="additional-name">R. R.</span> <span class="family-name">Martin</span></span></span></p>
</figure>

<p>In this example, the author and book title are only connected by proximity. You could connect them more explicitly using <a href="http://microformats.org/wiki/hproduct">the hProduct microformat</a>, <a href="http://wiki.goodrelations-vocabulary.org/Quickstart">RDFa’s GoodRelations</a>, or to really bleed on the edge even <a href="http://schema.org/Book">Schema.org</a>.</p>

<p>Note that you can’t use the now-Google-approved <code>rel="author"</code> attribute here, as <em>George R. R. Martin</em> is being referred to and isn’t writing the article. If you just wanted to style the author’s name, you could use <code>&lt;b class="author"&gt;</code> (gossip column style) or <code>&lt;span class="author"&gt;</code> with whatever CSS you like.</p>

<!-- /#cite-examples --></section>

<!-- /#cite --></section>

<section id="examples">
<h2>All together now <a class="permalink" href="#examples">#</a></h2>

<p>Oay, let’s start mixing things up on the operating table and show some examples of <code>&lt;cite&gt;</code> with <code>&lt;blockquote&gt;</code> and <code>&lt;q&gt;</code>:</p>

<figure>
<figcaption>A movie <code>&lt;blockquote&gt;</code> with <code>&lt;cite&gt;</code>:</figcaption>
<pre><code>&lt;blockquote&gt;
&lt;p&gt;You know the golden rule, don’t you boy? Those who have the gold make the rules.&lt;/p&gt;
&lt;footer&gt;— Crazy hunch-backed old guy in &lt;cite&gt;&lt;a href="http://en.wikipedia.org/wiki/Aladdin_(1992_Disney_film)"&gt;Aladdin&lt;/a&gt;&lt;/cite&gt;&lt;/footer&gt;
&lt;/blockquote&gt;
</code></pre>
<blockquote>
<p>You know the golden rule, don’t you boy? Those who have the gold make the rules.</p>
<footer>— Crazy hunch-backed old guy in <cite><a href="http://en.wikipedia.org/wiki/Aladdin_(1992_Disney_film)">Aladdin</a></cite></footer>
</blockquote>
</figure>

<figure>
<figcaption>Adding the <code>cite</code> attribute to a <code>&lt;blockquote&gt;</code> (and its <code>&lt;footer&gt;</code>):</figcaption>
<pre><code>&lt;blockquote cite="http://www.imdb.com/character/ch0000672/quotes"&gt;
&lt;p&gt;You know the golden rule, don’t you boy? Those who have the gold make the rules.&lt;/p&gt;
&lt;footer&gt;— &lt;a href="http://www.imdb.com/character/ch0000672/quotes"&gt;Crazy hunch-backed old guy&lt;/a&gt; in &lt;cite&gt;&lt;a href="http://en.wikipedia.org/wiki/Aladdin_(1992_Disney_film)"&gt;Aladdin&lt;/a&gt;&lt;/cite&gt;&lt;/footer&gt;
&lt;/blockquote&gt;
</code></pre>
<blockquote cite="http://www.imdb.com/character/ch0000672/quotes">
<p>You know the golden rule, don’t you boy? Those who have the gold make the rules.</p>
<footer>— <a href="http://www.imdb.com/character/ch0000672/quotes">Crazy hunch-backed old guy</a> in <cite><a href="http://en.wikipedia.org/wiki/Aladdin_(1992_Disney_film)">Aladdin</a></cite></footer>
</blockquote>
</figure>

<figure>
<figcaption>A quote from a specification:</figcaption>
<pre><code>&lt;p&gt;I wonder if feedback on &lt;code&gt;&amp;lt;cite&amp;gt;&lt;/code&gt; prompted this:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;A person's name is not the title of a work — even if people call that person a piece of work&lt;/p&gt;
&lt;footer&gt;&lt;cite&gt;&lt;a href="http://developers.whatwg.org/text-level-semantics.html#the-cite-element"&gt;HTML5 for Web Developers&lt;/a&gt;&lt;/cite&gt;&lt;/footer&gt;
&lt;/blockquote&gt;
</code></pre>
<p>I wonder if feedback on <code>&lt;cite&gt;</code> prompted this:</p>
<blockquote><p>A person's name is not the title of a work — even if people call that person a piece of work</p>
<footer>— <cite><a href="http://developers.whatwg.org/text-level-semantics.html#the-cite-element">HTML5 for Web Developers</a></cite></footer>
</blockquote>
</figure>

<figure>
<figcaption>An academic-style journal citation:</figcaption>
<pre><code>&lt;ol&gt;
&lt;li&gt;The information capacity of the human motor system in controlling the amplitude of movement, Paul M. Fitts (1954). &lt;cite&gt;Journal of Experimental Psychology&lt;/cite&gt;, volume 47, number 6, June 1954, pp. 381–391&lt;/li&gt;
&lt;/ol&gt;</code></pre>
<ol>
<li>The information capacity of the human motor system in controlling the amplitude of movement, Paul M. Fitts (1954). <cite>Journal of Experimental Psychology</cite>, volume 47, number 6, June 1954, pp. 381–391</li>
</ol>
</figure>

<figure>
<figcaption>An academic-style book citation:</figcaption>
<pre><code>&lt;blockquote&gt;
&lt;p&gt;Citations … all include the following: author (or editor, compiler, or translator standing in place of the author), title (and usually subtitle), and date of publication.&lt;/p&gt;
&lt;footer&gt;&lt;cite&gt;&lt;a href="http://www.chicagomanualofstyle.org/"&gt;The Chicago Manual of Style&lt;/a&gt;&lt;/cite&gt;, 15th Edition (Chicago: University of Chicago Press, 2003), 596&lt;/footer&gt;
&lt;/blockquote&gt;</code></pre>
<blockquote>
<p>Citations … all include the following: author (or editor, compiler, or translator standing in place of the author), title (and usually subtitle), and date of publication.</p>
<footer>— <cite><a href="http://www.chicagomanualofstyle.org/">The Chicago Manual of Style</a></cite>, 15th Edition (Chicago: University of Chicago Press, 2003), 596</footer>
</blockquote>
</figure>

<!-- /#examples --></section>

<section id="conclusion">
<h2>Conclusion <a class="permalink" href="#conclusion">#</a></h2>

<p>If you’ve made it this far, congratulations! You’ve now learned more about citing and quoting in HTML5 than you wanted to know ;) But don’t keep the knowledge to yourself — let us know in the comments what you think. We’d also love to hear how you’re using <code>&lt;blockquote&gt;</code>, <code>&lt;q&gt;</code>, and <code>&lt;cite&gt;</code> in HTML5. If you share your code snippets, remember to escape them!</p>

<!-- /#conclusion --></section>

<section id="updates">
<h2>Updates <a class="permalink" href="#updates">#</a></h2>
<ol>
<li><em><time datetime="2011-06-29T17:20:46+09:00">2011-06-29</time></em>: It seems our long-running convention at HTML5 Doctor of using <code>&lt;footer&gt;</code> for attribution inside a <code>&lt;blockquote&gt;</code> is in keeping with the <code>&lt;footer&gt;</code> part of the spec, but <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=13082" title="Bug 13082">not with the <code>&lt;blockquote&gt;</code> part</a>. We’re investigating…</li>
<li><em><time datetime="2011-07-03T23:52:47+09:00">2011-07-03</time></em>: Hixie confirmed that our use of <code>&lt;footer&gt;</code> is currently non-conforming — <code>&lt;footer&gt;</code> can currently only be included in <code>&lt;blockquote&gt;</code> if it’s quoted content. However, the phrase “content inside a blockquote must be quoted from another source” also forbids other <a href="http://oli.jp/example/blockquote-metadata/" title="Examples of block quote metadata ❧ Oli.jp (@boblet)">common changes and additions to block quotes</a>, so I’m going to see if it can be changed.</li>
<li><em><time datetime="2011-07-10T21:36:58+09:00">2011-07-10</time></em>: I wrote an article <a href="http://oli.jp/2011/blockquote/" title="Blockquote problems and solutions ❧ Oli.jp (@boblet)"><code>&lt;blockquote&gt;</code> problems and solutions</a> about these problems, and initial feedback from Hixie is that there are legitimate issues, and he’ll review <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-July/032334.html" title="[whatwg] The blockquote element spec vs common quoting practices">feedback via the WHATWG email list</a>. So, please do that! You can also leave feedback in the comments here or ping me on <a href="http://twitter.com/boblet">Twitter (@boblet)</a>. Also, don’t miss <a href="http://adactio.com/journal/4675/" title="Adactio: Journal&mdash;Citation needed">Jeremy Keith’s excellent commentary “Citation needed”</a> on the issue (watch out for those <code>&lt;cite&gt;</code>s though ;) )</li>
<li><em><time datetime="2011-09-23T12:55:16+12:00">2011-09-23</time></em>: I’ve added keyboard shortcuts for punctuation characters to the <a href="#punctuation-characters">punctuation table</a>, for default (typically US) keyboards.</li>
<li><em><time datetime="2012-02-14T15:21:56+13:00">2012-02-14</time></em> Added <a href="#change-2012-02-14">a note about Hixie’s reply</a> to the article.</li>
</ol>
<!-- /#updates --></section>


<!-- 
* <q> is only for quotes, not other uses such as sarcasm. use “” or ‘’ instead
  * http://en.wikipedia.org/wiki/Quotation_mark
* don’t add punctuation manually to <q>, one or the other
* use <blockquote> for >1 paragraph of text
 -->
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><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/i-b-em-strong-element/" rel="bookmark" class="crp_title">The i, b, em, &amp; strong elements</a></li><li><a href="http://html5doctor.com/the-scoped-attribute/" rel="bookmark" class="crp_title">The scoped 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/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/blockquote-q-cite/" rel="bookmark">Quoting and citing with <code>&lt;blockquote&gt;</code>, <code>&lt;q&gt;</code>, <code>&lt;cite&gt;</code>, and the cite attribute</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on June 28, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/blockquote-q-cite/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>HTML5 for Web Developers</title>
		<link>http://html5doctor.com/html5-for-web-developers/</link>
		<comments>http://html5doctor.com/html5-for-web-developers/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 14:30:09 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[Specification Changes]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[W3C]]></category>
		<category><![CDATA[WHATWG]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3061</guid>
		<description><![CDATA[<p>While they’re essential reading material for our job, W3C specifications tend to make for poor reading material. One intrepid developer set out to change this for himself — “HTML5 for Web Developers” is the fruit of his labours. In addition to introducing this awesome new resource, we make a delicious fruit salad for you by comparing it to the other HTML(5) specs.</p>]]></description>
			<content:encoded><![CDATA[<!-- 
<h1>An HTML5 spec for the rest of us</h1>
 -->

<p>While they’re essential reading material for our job, the <dfn><abbr title="World Wide Web Consortium">W3C</abbr></dfn> specifications are not exactly <a href="http://www.georgerrmartin.com/" title="George R. R. Martin's Official Website">George R. R. Martin</a>-level reading material. To make matters worse, the often-dry text (written for <em>implementors</em>, not authors) and…colourful illustrations come wrapped in a design straight out of 1999. While the <a href="http://www.w3.org/Help/about-redesign.html" title="About the W3C Site Redesign"><abbr>W3C</abbr> homepage got some lovin’</a> in 2009 from the dynamic duo of <a href="http://www.happycog.com/create/w3c/" title="The World Wide Web Consortium Website Redesign: Happy Cog">Happy Cog</a> and <a href="http://www.airbagindustries.com/archives/airbag/were_actively_w.php" title="Airbag - Completed.">Airbag Industries</a>, the actual specifications are still only slightly above the baseline of browser defaults. So what’s a caring developer to do?</p>

<p><a href="http://twitter.com/benschwarz">Ben Schwarz</a>, a developer in Melbourne, Australia, took matters into his own hands with a <a href="http://germanforblack.com/articles/moving-towards-readable-w3c-specs" title="W3C Design
— an article by Ben Schwarz">userscript to give <abbr>W3C</abbr> specs some <em>readability</em></a>. Around the same time <a href="http://people.w3.org/mike/" title="W3C &#187; People &#187; Michael[tm] Smith">Mike™ Smith</a> — the <abbr>W3C</abbr> team contact for HTML Working Group amongst other things — was looking for CSS help for <a href="http://dev.w3.org/html5/markup/" title="HTML5: The Markup Language Reference">HTML5: The Markup Language Reference</a>, his cut-down reference version of the HTML5 spec. I was able to introduce Mike™ and Ben, and the result was <a href="http://dev.w3.org/html5/spec-author-view/" title="HTML5 (Edition for Web Authors)">HTML5 Edition for Web Authors</a>. But this was only the start.</p>

<p>Ben then got on the <abbr>WHATWG</abbr> <abbr>IRC</abbr> channel:</p>

<blockquote>
<p>Within 10 minutes of joining the <abbr>WHATWG</abbr> <abbr>IRC</abbr> channel Ian Hickson had granted me approval to continue with my own build of the spec, targeted for web developers.</p>
<footer><cite>— <a href="http://www.germanforblack.com/articles/html5-for-web-developers">HTML5, for web developers</a></cite> announcement by Ben Schwarz</footer>
</blockquote>

<p>After a lot of hard work, with input and encouragement from the web’s finest (including Dr Bruce), Ben has released <a href="http://developers.whatwg.org/" title="HTML5 &mdash; Edition for Web Developers">HTML5 for Web Developers</a>.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/02/html5-for-web-devs-50.png" alt="HTML5 for Web Developers screenshot" width="552" height="424" class="aligncenter size-full wp-image-3075" />
<figcaption>HTML5 for Web Developers</figcaption>
</figure>

<blockquote>
<p>The focus of this specification is readability and ease of access. Unlike the full HTML specification, this “web developer edition” removes information that only browser vendors need know.</p>
<footer><cite>— <a href="http://developers.whatwg.org/">HTML5 for Web developers</a></cite></footer>
</blockquote>

<p>In addition to streamlining the content, it boasts all manner of freshly implemented buzzwords and technical trickery through the magicks<!-- intentional --> of JavaScript and CSS:</p>

<ul>
<li>find-as-you-type search (type “<kbd>/</kbd>”)</li>
<li>offline access</li>
<li>alternate styles for mobile devices</li>
<li>technical references pulled inline</li>
<li>beautiful typography</li>
<li>…and <em>design</em></li>
</ul>

<p>It’s been well received, with more than <a href="https://twitter.com/benschwarz/status/40292551848235008">20,000 uniques in the first 24 hours</a>, and the Pied Piper of HTML5 remarking:</p>

<blockquote>
<p>Enjoying the gorgeously readable presentation of <a href="http://developers.whatwg.org/" title="HTML5 &mdash; Edition for Web Developers">http://developers.whatwg.org/</a> Nice work, <a href="http://twitter.com/benschwarz">@benschwarz</a>.</p>
<footer><cite>— <a href="http://twitter.com/#!/adactio/status/39827347100278784">@adactio, 22 Feb</a></cite> by Jeremy Keith</footer>
</blockquote>

<p><a href="https://github.com/benschwarz/developers.whatwg.org">The files to build HTML5 for Web Developers are on GitHub</a>, so if you have any problems or suggestions <a href="https://github.com/benschwarz/developers.whatwg.org/issues">add an issue</a>. You can also fork the project and help out — I have!</p>

<section id="what-to-use">
<h3>…but what spec should I use?</h3>

<p>In <a href="http://html5doctor.com/html5-living-standard/" title="HTML as a Living Standard — For and Against | HTML5 Doctor">our previous article on “HTML as a Living Standard”</a>, guest author <a href="http://john.foliot.ca/" title="Unrepentant">John Foliot</a> voiced a valid concern that with several versions of the HTML5 specification, you might end up on a different one than you expected, so let’s have a look at the different versions. Using the <abbr>W3C</abbr> nomenclature, “implementors” are browser and tool makers, and “authors” are web developers, and I’ve linked to Editor’s Drafts rather than Working Drafts, as HTML5 is still in flux.</p>
</section><!-- /#what-to-use -->

<section id="full-versions">
<h3>The heavyweight specs</h3>

<section id="html5">
<h4><a href="http://dev.w3.org/html5/spec/" title="HTML5">HTML5 — A vocabulary and associated <abbr>API</abbr>s for HTML and XHTML</a> by <abbr>W3C</abbr> <!-- <a href="http://www.w3.org/TR/html5/" title="HTML5">Working draft</a> --></h4>

<p>The HTML5 spec on the <abbr>W3C</abbr> site. It’s smaller than the other specs because several parts (including <a href="http://www.w3.org/TR/microdata/" title="HTML Microdata">Microdata</a>, <a href="http://dev.w3.org/html5/2dcontext/" title="HTML Canvas 2D Context">Canvas 2D Context</a>, and <a href="http://dev.w3.org/html5/postmsg/" title="HTML5 Web Messaging">Web Messaging</a>) have been turned into their own specifications.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/02/html5-w3c-33.png" alt="HTML5 specification screenshot" width="368" height="282" class="aligncenter size-full wp-image-3076" />
<figcaption>The HTML5 specification (on w3.org)</figcaption>
</figure>
<p>I recommend this spec if you don’t follow HTML5 developments — e.g., if you’re not a reader of HTML5 Doctor. This is the specification being prepared for Last Call in May 2011, and it shouldn't change much from here on.</p>
</section><!-- /#html5 -->

<section id="html-living-standard">
<h4><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/" title="HTML Standard">HTML — Living Standard</a> by <dfn><abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr></dfn></h4>

<p>The HTML spec on the <abbr>WHATWG</abbr> site. It’s a superset of the HTML5 spec, including some things that the <abbr>W3C</abbr> has split into separate specs (see above). It also includes post-HTML5 features such as <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#webvtt-0" title="4.8.6 The video element &mdash; HTML Standard">Web Video Text Tracks (WebVTT)</a>, but it doesn’t include non-HTML-specific specs like <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webstorage.html" title="11 Web storage &#8212; Web Applications 1.0">Web Storage</a>, <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/network.html" title="10.3 Web sockets &#8212; Web Applications 1.0">Web Sockets API</a>, and <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/comms.html#server-sent-events" title="10 Communication &#8212; Web Applications 1.0">Server-sent Events</a>.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/02/html-whatwg-33.png" alt="HTML — Living Standard specification screenshot" width="368" height="282" class="aligncenter size-full wp-image-3073" />
<figcaption>HTML — Living Standard specification (on whatwg.org)</figcaption>
</figure>

<p>I recommend this spec if you are interested in HTML5 (and beyond) and wish to be actively involved. While it’s more liable to change (especially the new bits), it’s also likely to include improvements that haven’t made it into HTML5. It’s also what browser makers are looking at. You can also get to it quickly with the link <a href="http://whatwg.org/html" title="HTML Standard">http://whatwg.org/html</a>.</p>
</section><!-- /#html-living-standard -->

<section id="web-applications">
<h4><a href="http://www.whatwg.org/specs/web-apps/current-work/complete/" title="Web Applications 1.0">Web Applications 1.0</a></h4>

<p>This is <em>everything</em> the <abbr>WHATWG</abbr> is working on, including non-HTML-specific material (see above). It’s introduced with a photo of a kitchen sink ;)</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/02/web-applications-33.png" alt="Web Applications 1.0 specification screnshot" width="368" height="282" class="aligncenter size-full wp-image-3077" />
<figcaption>Web Applications 1.0 specification (on whatwg.org)</figcaption>
</figure>

<p>While this is pretty much the same as HTML — Living Standard, I don’t recommend it because it doesn’t have the ability to hide implementor details. However you’ll need it if you’re interested in <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webstorage.html" title="11 Web storage &#8212; Web Applications 1.0">Web Storage</a>, <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/network.html" title="10.3 Web sockets &#8212; Web Applications 1.0">Web Sockets API</a>, and <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/comms.html#server-sent-events" title="10 Communication &#8212; Web Applications 1.0">Server-sent Events</a>. You can get to it quickly with the link <a href="http://whatwg.org/C" title="Web Applications 1.0">http://whatwg.org/C</a>.</p>
</section><!-- /#web-applications -->
</section><!-- /#full-versions -->


<section id="author-versions">
<h3>Cut-down versions specifically for authors (us)</h3>

<section id="h-tml">
<h4><a href="http://dev.w3.org/html5/markup/" title="HTML5: The Markup Language Reference">HTML5: The Markup Language Reference</a> <!-- <a href="http://www.w3.org/TR/html-markup/" title="HTML: The Markup Language Reference">Working draft</a> --></h4>

<p>A quick reference <em>for authors</em> describing the syntax, structure, and semantics of HTML5. It's intended to be <q>as concise and readable as possible</q>. From <a href="http://twitter.com/benschwarz/status/39891483897102336">the legend</a> and <a href="http://twitter.com/sideshowbarker">self-styled <abbr>W3C</abbr> HTML5 jackass</a> himself, Mike™ Smith, who also gets bonus points for the initialism “H:TML”.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/02/h-tml-33.png" alt="HTML5: The Markup Language Reference screenshot" width="368" height="282" class="aligncenter size-full wp-image-3071" />
<figcaption>HTML5: The Markup Language Reference (on w3.org)</figcaption>
</figure>

<p>I recommend this as a quick reference or cheat sheet to remind yourself of the essentials (well, in addition to the <a href="http://html5doctor.com/glossary/" title="Glossary | HTML5 Doctor">HTML5 Doctor glossary</a>, of course ;-). It doesn’t have the depth of guidance or the examples in the other specs (or the implementor details), but it has info links to <a href="http://developers.whatwg.org/" title="HTML5 &mdash; Edition for Web Developers">HTML5 for Web Developers</a>, so you can easily get more detailed information.</p>
</section><!-- /#h-tml -->

<section id="html5-for-web-authors">
<h4><a href="http://dev.w3.org/html5/spec-author-view/" title="HTML5 (Edition for Web Authors)">HTML5 (Edition for Web Authors)</a> <!-- <a href="http://www.w3.org/TR/html5/author/" title="HTML5 (Edition for Web Authors)">Working draft</a> --></h4>

<p>HTML5 for Web Authors was Mike™ and Ben’s first collaboration. It removes the implementation details intended for browser makers and adds some style, and it’s more in line with <abbr>W3C</abbr>’s HTML5 in that it doesn’t include microdata. For the time being, it’s been superseded by <a href="http://developers.whatwg.org/" title="HTML5 &mdash; Edition for Web Developers">HTML5 for Web Developers</a>.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/02/html-for-web-authors-33.png" alt="HTML5 for Web Authors screenshot" width="368" height="282" class="aligncenter size-full wp-image-3072" />
<figcaption>HTML5 for Web Authors (on w3.org)</figcaption>
</figure>

<p>I recommend this for JavaScripters, as it includes more API information than HTML5 for Web Developers. Currently it’s not as up-to-date as HTML5 for Web Developers, but I expect it to receive some love in the future.</p>
</section><!-- /#html5-for-web-authors -->

<section id="html5-for-web-developers">
<h4><a href="http://developers.whatwg.org/" title="HTML5 &mdash; Edition for Web Developers">HTML5 for Web Developers</a></h4>

<p>HTML5 for Web Developers also removes the implementation details intended for browser makers, but includes some parts like microdata that have been cut from <abbr>W3C</abbr>’s HTML5 spec. I’m very impressed with the functionality and design, and I expect it to keep improving.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/02/html5-for-web-devs-33.png" alt="HTML5 for Web Developers screenshot" width="368" height="282" class="aligncenter size-full wp-image-3074" />
<figcaption>HTML5 for Web Developers (on whatwg.org)</figcaption>
</figure>

<p>I recommend this for anyone wanting a beautiful, readable version of HTML5. With local storage, it’s also perfect for adding to an iPad home screen. As <a href="https://github.com/benschwarz/developers.whatwg.org">it’s on GitHub</a>, it’s also the only spec where <em>you</em> can easily contribute to the design and functionality.</p>
</section><!-- /#html5-for-web-developers -->

<p>There’s a bunch of other related Editor’s drafts linked to in the <a href="http://www.w3.org/html/wg/" title="W3C HTML Working Group">HTML Working Group sidebar</a> which may interest you. Lachlan Hunt’s <a href="http://dev.w3.org/html5/html-author/" title="HTML 5 Reference">HTML 5 Reference</a> — a learning rather than reference-focused version of the HTML5 spec — is unfortunately currently out-of-date and on ice, so I don’t recommend it.</p>
</section><!-- /#author-versions -->

<section id="summary">
<h3>In Summary</h3>

<p>I think these specs all have their place. Personally I’ve been mainly using the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/" title="HTML Standard">HTML — Living Standard</a> version, but expect to use <a href="http://developers.whatwg.org/" title="HTML5 &mdash; Edition for Web Developers">HTML5 for Web Developers</a> a lot now too. The differences between these different versions of HTML5 (except for <a href="http://dev.w3.org/html5/markup/" title="HTML5: The Markup Language Reference">H:TML</a>) can be broken down into two groups: the extra modules they include, and whether they include the option to show/hide implementor details — the HTML5 and HTML specs both do.</p>

<p>One fear <a href="http://html5doctor.com/html5-living-standard/" title="HTML as a Living Standard — For and Against | HTML5 Doctor">John Foliot expressed</a> is that you might accidentally end up using something that was highly likely to change. The <abbr>WHATWG</abbr> HTML and Web Applications specs, however, have annotations indicating the status of each item in the margin.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2011/02/annotations.png" alt="WHATWG annotations widget screenshot" width="500" height="200" class="aligncenter size-full wp-image-3070" />
<figcaption>An example of the <a href="http://www.whatwg.org/specs/web-apps/current-work/status-documentation.html" title="Specification annotation system documentation"><abbr>WHATWG</abbr>’s annotation notes</a></figcaption>
</figure>

<p>Handy!</p>
</section><!-- /#summary -->

<section id="addendum">
<h3>Addendum — a call to arms</h3>

<p>More generally, Ben also recently wrote an article encouraging everyone to <a href="http://germanforblack.com/articles/taking-the-web-back" title="Taking the web back
— an article by Ben Schwarz">get involved in the web standards process</a>. <abbr>WHATWG</abbr> and <abbr>W3C</abbr> are actively seeking feedback and suggestions regarding their work (as is Ben), and you can <a href="http://wiki.whatwg.org/wiki/What_you_can_do" title="What you can do - WHATWG Wiki">participate in various ways</a>:</p>

<ul>
<li>Read the spec and send comments via the <a href="http://lists.w3.org/Archives/Public/public-html/" title="public-html@w3.org Mail Archives">HTML WG</a> and/or <a href="http://www.whatwg.org/mailing-list" title="Web Hypertext Application Technology Working Group Mailing List"><abbr>WHATWG</abbr> mailing lists</a></li>
<li>Contribute feedback directly on the HTML5 and HTML — Living Standard specs via the feedback widget</li>
<li>Contribute feedback via the <a href="http://www.w3.org/Bugs/Public/enter_bug.cgi" title="Log in to Bugzilla">W3 bug tracker</a> (you’ll need a free account)</li>
<li>Join the HTML WG as a (self-)invited expert</li>
<li>Join the <a href="http://wiki.whatwg.org/wiki/IRC" title="IRC - WHATWG Wiki"><abbr>WHATWG</abbr> <abbr>IRC</abbr> chat room</a> or <a href="http://forums.whatwg.org/" title="WHATWG HTML Forums :: Index">forum</a></li>
<li>Use recently implemented features in personal sites and give feedback</li>
<li>Write about your experiences using new features</li>
<li>Make demos to show new features (or, for the truly gifted, JavaScript mockups of proposed features)</li>
<li>Or, you know, just <a href="http://developers.whatwg.org/" title="HTML5 &mdash; Edition for Web Developers"><em>create a whole new way to view the spec</em></a></li>
</ul>

<p>Here at <a href="http://html5doctor.com/" title="HTML5 Doctor, helping you implement HTML5 today">HTML5 Doctor</a>, we’re doing our bit. I really hope you’re inspired by the backstory of HTML5 for Web Developers and see how low the barrier of entry is — inspired into <em>action!</em> We can (and should) all contribute to the future of the web.</p>

</section><!-- /#addendum -->

<p>I’ll leave the last words to Ben himself, who, a day after launching, said:</p>

<blockquote>
<p>I'm thrilled to have it out, see good community support, and I hope that it becomes a reference for people to use every day</p>
<footer>— Ben Schwarz</footer>
</blockquote>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/html5-living-standard/" rel="bookmark" class="crp_title">HTML as a Living Standard — For and Against</a></li><li><a href="http://html5doctor.com/two-cheers-for-the-w3cs-html5-logo/" rel="bookmark" class="crp_title">Two cheers for the W3C&#8217;s HTML5 logo</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/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></ul></div><p><a href="http://html5doctor.com/html5-for-web-developers/" rel="bookmark">HTML5 for Web Developers</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on February 25, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/html5-for-web-developers/feed/</wfw:commentRss>
		<slash:comments>9</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>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>The ruby element and her hawt friends, rt and rp</title>
		<link>http://html5doctor.com/ruby-rt-rp-element/</link>
		<comments>http://html5doctor.com/ruby-rt-rp-element/#comments</comments>
		<pubDate>Tue, 11 May 2010 14:00:55 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[rp]]></category>
		<category><![CDATA[rt]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1745</guid>
		<description><![CDATA[<p>The <code>&#60;ruby&#62;</code>, <code>&#60;rt&#62;</code> and <code>&#60;rp&#62;</code> elements allow us to add ‘ruby’ phonetic annotations in languages like Japanese and Chinese. Despite the terrors of internationalisation and patchy browser support — with a little fiddling and a lot of caution — this sexy threesome with adorable accents are ready to use now.</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Ruby_character" title="Ruby character - Wikipedia, the free encyclopedia">Ruby text</a> is a short annotation for some base text. It’s typically used to give pronunciation guidance in a phonetic script for kanji in Chinese, Japanese, and Korean (<abbr title="Chinese, Japanese and Korean">CJK</abbr>) languages. It’s named after an old printers’ term for the very small size of 5.5 points.</p>

<blockquote cite="http://dev.w3.org/html5/markup/ruby">
<p>The ruby element allows spans of phrasing content to be marked with ruby annotations.</p>
<cite><a href="http://dev.w3.org/html5/markup/ruby" title="HTML5: ruby — ruby annotation (NEW)">W3C Specification</a></cite>
</blockquote>

<p>As the name implies, ruby text is small<!-- IE=6pt, Webkit=60% -->, displayed by default above the base text in horizontal text and to the right in vertical text. Browsers without <code>&lt;ruby&gt;</code> support put the ruby text inline after the base text.</p>

<p>These are the elements used in creating ruby text in <abbr>HTML</abbr>5:</p>

<ul>
<li><code>&lt;ruby&gt;</code> — an inline element that contains base text with ruby annotations</li>
<li><code>&lt;rt&gt;</code> — ruby text, coming after the base text it defines</li>
<li><code>&lt;rp&gt;</code> — ruby parentheses, an element used to wrap opening and closing parentheses around <code>&lt;rt&gt;</code> ruby text. These are for user agents that don’t support ruby text, so that it makes sense when displayed inline. Browsers that support <code>&lt;ruby&gt;</code> hide <code>&lt;rp&gt;</code> via <code>{display:none;}</code>.</li>
</ul>

<section id="examples">
<h2>Examples</h2>

<p>If you’ve never seen ruby in action you’re probably wondering what I’m talking about, so here are some examples:</p>

<figure>
<img src="/wp-content/uploads/2010/05/vagabond.jpg" width="279" height="250" alt="Vagabond">
<figcaption><i lang="ja-latn">Furigana</i> ruby text in the Japanese manga <a href="http://en.wikipedia.org/wiki/Vagabond_(manga)" title="Vagabond (manga) - Wikipedia, the free encyclopedia">Vagabond</a></figcaption>
</figure>

<figure>
<img src="/wp-content/uploads/2010/05/bopomofo-newspaper.png" width="38" height="147" alt="Bopomofo Newspaper" />
<figcaption>Snippet of a <a href="http://wss.djes.tp.edu.tw/report/Lists/Photos/951222%E5%9C%8B%E8%AA%9E%E6%97%A5%E5%A0%B1/%E5%9C%8B%E8%AA%9E%E6%97%A5%E5%A0%B1.jpg" title="Image of a Taiwanese newspaper with bopomofo ruby for students">Taiwanese newspaper for students</a>, with <i lang="zh-latn">bopomofo</i> ruby</figcaption>
</figure>

<figure>
<img src="/wp-content/uploads/2010/05/chosun.png" width="405" height="72" alt="Typical Korean usage of hanji in a Korean news website" />
<figcaption>Korean <i lang="kr-latn">hangul</i> followed by <i lang="kr-latn">hanja</i> in an editorial on <a href="http://news.chosun.com/site/data/html_dir/2010/04/19/2010041902457.html">Chosun.com</a></figcaption>
</figure>

</section>

<section id="browser-support">
<h2>Browser support</h2>

<p>As is often the way with internationalisation features, browser support is — well, sparse. In a break from your expectations, Internet Explorer has supported <code>&lt;ruby&gt;</code> since <abbr>IE</abbr>5 — three years before the actual 2001 <a href="http://www.w3.org/TR/ruby/" title="Ruby Annotation">W3C Ruby Annotation</a> specification! While this specification was incorporated into <a href="http://www.w3.org/TR/xhtml11/changes.html#a_changes" title="XHTML 1.1 - Changes from XHTML 1.0 Strict"><abbr>XHTML</abbr> 1.1</a>, no browser ever implemented it.</p>

<p><code>&lt;ruby&gt;</code> in <abbr>HTML</abbr>5 is based on a reverse-engineering of <abbr>IE</abbr>’s implementation. It also lacks Ruby Annotation’s ‘complex <code>&lt;ruby&gt;</code>’, as these can normally be accomplished via nesting. (Please submit feedback if you have a real-world example that can’t be.) <a href="http://webkit.org/blog/948/ruby-rendering-in-webkit/" title="Surfin’ Safari - Blog Archive  » Ruby Rendering in WebKit">Webkit</a> added <abbr>HTML</abbr>5 <code>&lt;ruby&gt;</code> support at the start of 2010. At the time of writing, <code>&lt;ruby&gt;</code> has made it into Chrome but not Safari. Firefox and Opera have yet to implement <code>&lt;ruby&gt;</code> natively, although there are Firefox extensions for <code>&lt;ruby&gt;</code> support (<a href="http://htmlruby.codeplex.com/" title="HTML Ruby"><abbr>HTML</abbr> Ruby (basic ruby including <abbr>HTML</abbr>5)</a> and <a href="http://piro.sakura.ne.jp/xul/_rubysupport.html.en" title="XUL Apps &gt; XHTML Ruby Support - outsider reflex"><abbr>XHTML</abbr> Ruby (complex ruby)</a>).</p>

<p>On the styling side, there’s the <a href="http://www.w3.org/TR/css3-ruby/" title="CSS3 Ruby Module">W3C <abbr>CSS</abbr>3 Ruby Module</a> (2003). It’s based on Ruby Annotation’s ‘complex ruby’ and is being updated for <abbr>HTML</abbr>5 <code>&lt;ruby&gt;</code>. Because of this, it’s also yet to be implemented beyond the default <abbr>IE</abbr>-level formatting. Ruby text will be used in combination with the <a href="http://dev.w3.org/csswg/css3-text-layout/" title="CSS Text Layout Module Level 3">W3C <abbr>CSS</abbr> Text Layout Module Level 3</a> properties <code>direction</code>, <code>block-flow</code>, and <code>writing-mode</code> for alternative text flow (such as vertical text), but again these have <a href="http://www.zachleat.com/web/2010/02/12/css3-text-writing-mode/" title="CSS 3 Text: A Tale of writing-mode Woe">poor implementation</a>.</p>

<table>
<caption>Summary of browser support for <code>&lt;ruby&gt;</code> display &amp; styling in the five main browsers</caption>
<thead>
<tr>
<th>Browser</th>
<th>Basic <code>&lt;ruby&gt;</code></th>
<th><code>writing-mode</code></th>
<th>‘Complex <code>&lt;ruby&gt;</code>’</th>
<th><abbr>CSS</abbr>3 Ruby (2003)</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Internet Explorer</th>
<td><abbr>IE</abbr>5.5+</td>
<td><abbr>IE</abbr>6+<a href="#css-note1">*</a></td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<th scope="row">Firefox</th>
<td>(via plugin)</td>
<td>-</td>
<td>(via plugin)</td>
<td>-</td>
</tr>
<tr>
<th scope="row">Chrome</th>
<td>Chrome5+</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<th scope="row">Safari</th>
<td>Safari5+</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<th scope="row">Opera</th>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
</tbody>
</table>
<p id="css-note1">Note: <code>writing-mode</code> support in <abbr>IE</abbr>6 was <code>lr-tb</code> and <code>tb-rl</code> only. <a href="http://blogs.msdn.com/ie/archive/2009/05/29/the-css-corner-writing-mode.aspx" title="IEBlog : The CSS Corner: writing-mode"><abbr>IE</abbr>8 added support for all possible combinations</a>.</p>

<section id="usable-css">
<h3><abbr>CSS</abbr> we <em>can</em> use</h3>

<p>Having said that no browsers support the <abbr>CSS</abbr>3 Ruby module yet, there are still a few things we can do to style <code>&lt;ruby&gt;</code> and friends. Default browser styles use <code>font-size</code> and <code>display</code>, so we can safely change these to affect display in both supporting and non-supporting browsers.</p>

<p>If you want to de-emphasise the <code>&lt;rt&gt;</code> ruby text when it’s displayed inline in non-supporting browsers, you could do this via setting the size of <code>&lt;rt&gt;</code> and <code>&lt;rp&gt;</code>, as <abbr>IE</abbr> and Webkit do:</p>

<pre><code>rt, rp {font-size: 60%;} /* = Webkit value */</code></pre>

<p>You can also move ruby text and parentheses to after the base text, mimicking non-supporting browser rendering on supporting browsers:</p>

<pre><code>rt, rp {display: inline; font-size: 100%;}</code></pre>

<p>Finally, if you’re brave/foolish, you can implement ruby display yourself via <abbr>CSS</abbr> <code>inline-table</code> (<a href="http://sideshowbarker.net/2009/11/13/html5-ruby/#comment-3388" title="Carl’s ‘faking ruby’ comment on Mike Smith’s weblog"><abbr>CSS</abbr> with explanation</a> and <a href="http://hiragana.jp/" title="Hiragana Megane (How to Read Japanese)">demonstration (Hiragana.jp)</a>). Note that <a href="https://bugs.webkit.org/show_bug.cgi?id=36803">this currently doesn’t work in Chrome</a> because of a bug with <code>display:inline-table</code> on <code>&lt;ruby&gt;</code> (fixed in trunk), and as you’ll probably need per-browser style tweaks, I recommend against it.</p>

</section>
</section>

<section id="code-samples">
<h2>Code samples and output</h2>

<p><a href="http://oli.jp/example/ruby/" title="Ruby examples ❧ Oli.jp (@boblet)">These code samples</a> (with notes and <abbr>CSS</abbr>) are also available separately.</p>

<section id="ja">
<h3><code>&lt;ruby&gt;</code> in Japanese — <i lang="ja-latn">furigana</i> and <i lang="ja-latn" title="romaji">rōmaji</i></h3>

<section id="without-rp">
<h4>Using <code>&lt;ruby&gt;</code> without <code>&lt;rp&gt;</code></h4>
<figure>
<pre><code>&lt;ruby&gt;攻殻&lt;rt&gt;こうかく&lt;/rt&gt;機動隊&lt;rt&gt;きどうたい&lt;/rt&gt;&lt;/ruby&gt;</code></pre>
<img src="/wp-content/uploads/2010/05/gits.png" width="100" height="50" alt="Furigana example using ruby in a supporting browser (displayed above base text)" />
<img src="/wp-content/uploads/2010/05/gits-inline.png" width="235" height="50" alt="Furigana example using ruby in a non-supporting browser (displayed inline after base text)">
<figcaption>Using <code>&lt;ruby&gt;</code> to indicate the pronunciation of the Japanese name of the <a href="http://en.wikipedia.org/wiki/Ghost_in_the_shell" title="Ghost in the Shell - Wikipedia, the free encyclopedia">Ghost in the Shell anime series</a> in <i lang="ja-latn">furigana</i>. Notice that the lack of <code>&lt;rp&gt;</code> makes it pretty unreadable in a non-supporting browser (you may have to trust me on this!).<!-- this could be faked in browsers supporting generated content via rt:before {content: "(";} and rt:after {content: ")";}, but you can’t then turn it off for supporting browsers --></figcaption>
</figure>
</section>

<section id="with-rp">
<h4>Using <code>&lt;ruby&gt;</code> with <code>&lt;rp&gt;</code></h4>
<figure>
<pre><code>&lt;ruby&gt;攻殻&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;こうかく&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;機動隊&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;きどうたい&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;&lt;/ruby&gt;</code></pre>
<img src="/wp-content/uploads/2010/05/gits.png" width="100" height="50" alt="Furigana example using ruby in a supporting browser (displayed above base text)" />
<img src="/wp-content/uploads/2010/05/gits-parentheses.png" width="300" height="50" alt="Furigana example using ruby in a non-supporting browser (displayed inline with parentheses)" />
<figcaption>The above example with <code>&lt;rt&gt;</code> text surrounded by <code>&lt;rp&gt;</code> parentheses degrades gracefully on non-supporting browsers.</figcaption>
</figure>
</section>

<section id="nested-ruby">
<h4>Nested <code>&lt;ruby&gt;</code> for multiple ruby texts</h4>
<figure>
<pre><code>&lt;ruby&gt;&lt;ruby&gt;攻&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;こう&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;殻&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;かく&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;機&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;き&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;動&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;どう&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;隊&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;たい&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;&lt;/ruby&gt;&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;Kōkakukidōtai&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;&lt;/ruby&gt;</code></pre>
<img src="/wp-content/uploads/2010/05/gits-two-ruby.png" width="110" height="50" alt="Two ruby texts in a supporting browser (both displayed above base text)">
<img src="/wp-content/uploads/2010/05/gits-two-ruby-paren.png" width="520" height="36" alt="Two ruby texts in a non-supporting browser (displayed inline in source order)">
<figcaption>The scope of <code>&lt;rt&gt;</code> depends on the amount of base text before it, from one character to an entire phrase. <code>&lt;ruby&gt;</code> can also be nested to provide multiple ruby texts for one base text — in this case <i lang="ja-latn">furigana</i> and <i lang="ja-latn" title="romaji">rōmaji</i>. Although per-kanji <code>&lt;ruby&gt;</code> is more informative, it degrades somewhat poorly in non-supporting browsers. Copy &amp; paste support is also poor, as browsers just use source order, for example “攻こう殻かく機き動どう隊たい Kōkakukidōtai”. It’s also a <abbr title="pain in the arse">PITA</abbr> to code :-|</figcaption>
</figure>
</section>

<!-- Example of vertical text? -->

<section id="jp-glossary">
<h4>Japanese glossary</h4>

<p><i lang="ja-latn">Furigana</i> is the name given to using <i lang="ja-latn">hiragana</i> phonetic script beside words written in kanji to aid reading. It’s used extensively in education for learners of Japanese, and in reading material for children. It’s also sometimes used when writing kanji a literate adult may not be able to read.</p>

<p><i lang="ja-latn" title="romaji">Rōmaji</i> is the romanisation of Japanese into the latin alphabet. <i lang="ja-latn" title="romaji">Rōmaji</i> is generally used for those who don’t know Japanese, especially in signage and tourism information.</p>
</section>

</section>

<section id="zh">
<h3><code>&lt;ruby&gt;</code> in Chinese — <i lang="zh-latn" title="pinyin">Pīnyīn</i> and <i lang="zh-latn" Title="Zhuyin Fuhao">zhùyīn fúhào</i> (<i lang="zh-latn">bopomofo</i>)</h3>

<p>Ruby is used to some extent in China (<i lang="zh-latn" title="pinyin">pīnyīn</i>), and more so in Taiwan (<i lang="zh-latn" Title="Zhuyin Fuhao">zhùyīn fúhào</i>), especially in textbooks and signage.</p>

<section id="pinyin">
<h4><i lang="zh-latn" title="pinyin">Pīnyīn</i></h4>
<figure>
<pre><code>&lt;p&gt;The &lt;b&gt;Grass mud horse&lt;/b&gt; — &lt;ruby&gt;草泥馬&lt;rp&gt;(&lt;/rp&gt;&lt;rt&gt;Cǎo Ní Mǎ&lt;/rt&gt;&lt;rp&gt;)&lt;/rp&gt;&lt;/ruby&gt; — is … characterised as “lively, intelligent and tenacious”. However, their existence is said to be threatened by the “river crabs” — &lt;ruby class="styled"&gt;河蟹&lt;rp&gt; (&lt;/rp&gt;&lt;rt&gt;héxiè&lt;/rt&gt;&lt;rp&gt;) &lt;/rp&gt;&lt;/ruby&gt; — which are invading their habitat.&lt;/p&gt;</code></pre>
<img src="/wp-content/uploads/2010/05/gmh.png" width="570" height="100" alt="Ruby text in a paragraph of text in a supporting browser, leading to significant line-height differences">
<img src="/wp-content/uploads/2010/05/gmh-combo.png" width="570" height="80" alt="Ruby text in a non-supporting browser, with font-size set on rt and rp elements for the second ruby instance">
<figcaption>In this example of <i lang="zh-latn">pinyin</i> you can see how <code>&lt;ruby&gt;</code> significantly affects the leading (<code>&lt;line-height&gt;</code>) of text blocks in supporting browsers. Setting <code>font-size</code> for <code>&lt;rt&gt;</code> and <code>&lt;rp&gt;</code> can de-emphasise ruby text in non-supporting browsers, as demonstrated in the second <code>&lt;ruby&gt;</code> in the second image.</figcaption>
</figure>
</section>

<section id="bopomofo">
<h4><i lang="zh-latn" Title="Zhuyin Fuhao">Zhùyīn fúhào</i></h4>
<figure>
<pre><code>&lt;ruby&gt;&lt;ruby&gt;世&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄕˋ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;上&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄕㄤˋ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;無&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄨˊ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;難&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄋㄢˊ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;事&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄕˋ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;只&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄓˇ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;怕&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄆㄚˋ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;有&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄧㄡˇ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;心&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄒㄧㄣ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;人&lt;rp&gt;（&lt;/rp&gt;&lt;rt&gt;ㄖㄣˊ&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;&lt;/ruby&gt;&lt;rp&gt; （&lt;/rp&gt;&lt;rt&gt;Anything can be done with enough perseverance&lt;/rt&gt;&lt;rp&gt;）&lt;/rp&gt;&lt;/ruby&gt;</code></pre>
<img src="/wp-content/uploads/2010/05/bopomofo.png" width="471" height="56" alt="How this bopomofo *should* look in a supporting browser (which doesn’t exist as far as I know)" />
<img src="/wp-content/uploads/2010/05/bopomofo-chrome.png" width="230" height="55" alt="This bopomofo example in Chrome" />
<img src="/wp-content/uploads/2010/05/bopomofo-firefox.png" width="467" height="84" alt="This bopomofo example in Firefox" />
<!-- http://en.wikiquote.org/wiki/Chinese_proverbs -->
<figcaption>Unfortunately, no browser can render this example of <i lang="zh-latn" Title="Zhuyin Fuhao">Zhùyīn fúhào</i> (<i lang="zh-latn">bopomofo</i>) ruby on horizontal Mandarin Chinese correctly. I’ve included an ideal rendering and how it appears in both a browser supporting simple ruby (with incorrectly rendered <i lang="zh-latn">bopomofo</i>) and a non-supporting browser.</figcaption>
</figure>
</section>

<section id="zh-glossary">
<h4>Chinese glossary</h4>
<p><a href="http://en.wikipedia.org/wiki/Pinyin" title="Pinyin - Wikipedia, the free encyclopedia"><i lang="zh-latn" title="pinyin">Pīnyīn</i></a> is a romanised phonetic system for Chinese, generally written above or after the word. <a href="http://en.wikipedia.org/wiki/Bopomofo" title="Bopomofo - Wikipedia, the free encyclopedia"><i lang="zh-latn">Bopomofo</i> (<i lang="zh-latn" Title="Zhuyin Fuhao">Zhùyīn fúhào</i>)</a> is a phonetic script for transcribing Chinese, especially Mandarin. It is generally written (in both horizontal and vertical scripts) vertically to the right of each <i lang="ja-latn">hanzi</i> character.</p>
</section>
</section>

<section id="ko">
<h3>Korean ruby</h3>
<p>While the use of <i lang="ko-latn">hanja</i> (kanji) is decreasing in South Korea, they are still used for disambiguation and proper names.</p>

<figure>
<pre><code>&lt;ruby&gt;한자&lt;rp&gt;(&lt;/rp&gt;&lt;rt&gt;漢字&lt;/rt&gt;&lt;rp&gt;)&lt;/rp&gt;&lt;/ruby&gt;</code></pre>
<img src="/wp-content/uploads/2010/05/hanja.png" alt="Hangul followed inline by hanja in brackets">
<figcaption>Current Korean ruby use is to have the <i lang="kr-latn">hangul</i> coming <em>before</em> the <i lang="kr-latn">hanja</i> in parentheses (the opposite way from the default fallback style). For styling use: <code>rt, rp {display: inline; font-size: 100%;}</code>. This formatting is also used when foreign words such as English are included in Korean text.</figcaption>
</figure>

<section id="ko-glossary">
<h4>Korean glossary</h4>
<p><a href="http://en.wikipedia.org/wiki/Hangul" title="Hangul - Wikipedia, the free encyclopedia"><i lang="kr-latn">Hangul</i></a> is the Korean script, and <a href="http://en.wikipedia.org/wiki/Hanja" title="Hanja - Wikipedia, the free encyclopedia"><i lang="kr-latn">hanja</i></a> is Korean for Chinese characters. Traditionally written Korean used <i lang="kr-latn">hanja</i>, but now it’s mainly used in academic texts and occasionally for disambiguation.</p>
</section>
</section>

<section id="en">
<h3>Using <code>&lt;ruby&gt;</code> for English</h3>

<p>Not everyone is using East Asian languages, but any short annotation is (theoretically) applicable. While English doesn’t typically have pronunciation guidance, phonetic annotations are used in dictionaries:</p>

<!-- styled to make rt appear inline -->
<figure>
<pre><code>&lt;ruby&gt;&lt;strong&gt;cromulent&lt;/strong&gt; &lt;rp&gt;(&lt;/rp&gt;&lt;rt&gt;crôm-yü-lənt&lt;/rt&gt;&lt;rp&gt;)&lt;/rp&gt;&lt;/ruby&gt;</code></pre>
<img src="/wp-content/uploads/2010/05/cromulent.png" width="570" height="80" alt="Displaying ruby text after the base text for an English dictionary">
<figcaption>Using ruby text for a dictionary definition by displaying the ruby text inline after the base text</figcaption>
</figure>
</section>
</section>

<section id="use-it">
<h2><code>&lt;ruby&gt;</code>: to use or not to use</h2>

<p>The main use case of <code>&lt;ruby&gt;</code> is marking up pronunciation in Asian writing, such as <i lang="zh-latn" title="phonetic system for transcribing Chinese">bopomofo</i> for traditional Chinese and <i lang="ja-latn" title="addition of small kana next to kanji to aid reading">furigana</i> for Japanese. I don’t know whether Arabic diacritics like Taškīl, Hebrew Niqqud, or other non-<abbr title="Chinese, Japanese and Korean languages">CJK</abbr> languages would use <code>&lt;ruby&gt;</code> for marking up phonetic annotations or diacritics. The <abbr>WHATWG</abbr> specification says:</p>

<blockquote>
<p>Ruby annotations are short runs of text presented alongside base text, primarily used in East Asian typography as a guide for pronunciation or to include other annotations</p>
<footer><cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-ruby-element" title="4.6 Text-level semantics &mdash; HTML5 (including next generation additions still in development)">WHATWG specification</a></cite></footer>
</blockquote>

<p>As someone who uses tools like <a href="http://www.popjisyo.com/WebHint/Portal_e.aspx" title="POPjisyo.com - Dictionary Translation Japanese/Chinese/Korean/Kanji/Hanzi">Popjisyo</a> to add pop-up readings and translations to kanji, I definitely see <code>&lt;ruby&gt;</code> as semantic (and valuable) for ‘phonetic annotation,’ in the same way that <code>&lt;abbr&gt;</code> provides extra information on potentially confusing content. Outside of this usage, however, <code>&lt;ruby&gt;</code> could be seen as a presentational hack. Oh noes! I believe the Korean and English examples above are valid uses, but much like <code>&lt;q&gt;</code> some people think the extra code of using <code>&lt;ruby&gt;</code> is not justified when the default presentation is the same as plain text.</p>

<p>To further muddy the waters, the 2001 W3 Ruby specification included an <a href="http://www.w3.org/TR/ruby/#fig1.6" title="Ruby Annotation">abbreviated word marked up with a visible definition via <code>&lt;ruby&gt;</code></a>, and <a href="http://www.w3.org/TR/ruby/#fig1.9" title="Ruby Annotation">a use-by date where the day, month, and year are added via <code>&lt;ruby&gt;</code></a>. These uses seem like presentational hacks to me, and while they’re not forbidden, the lack of such examples in <abbr>HTML</abbr>5 indicate they’re not exactly blessed either ;-)</p>
</section>

<section id="conclusion">
<h2>In conclusion…</h2>

<p>The most important thing is that the <code>&lt;ruby&gt;</code>, <code>&lt;rt&gt;</code>, and <code>&lt;rp&gt;</code> elements are <em>valid <abbr>HTML</abbr>5</em>, and even if they’re not officially supported, they will by default display <em>as if they were <code>&lt;span&gt;</code>s</em> in non-supporting browsers. Because of this, <strong>if you actually need to use <code>&lt;ruby&gt;</code>, especially for phonetic annotations, do it</strong>! It might not look perfect yet in non-supporting browsers, but this will change, and hey, at least you don’t have <abbr>IE</abbr> support to worry about! ;-)</p>

<p>For non-phonetic annotation, consider using <code>&lt;abbr&gt;</code> to give an expanded reading via mouse-over for an abbreviation or acronym, unless displaying the reading by default is important. Consider <code>&lt;small&gt;</code> for <em>phrasing content</em>-level side comments, if the comment placement is not important and the association with the relevant content doesn’t need to be explicit.</p>
</section>

<section id="ref">
<h2>Further reading</h2>

<ul>
<li><a href="http://webkit.org/blog/948/ruby-rendering-in-webkit/" title="Surfin&#8217; Safari - Blog Archive  &raquo; Ruby Rendering in WebKit">Ruby rendering in Webkit</a> announcement on the Safari weblog</li>
<li><a href="http://my.opera.com/tagawa/blog/the-html5-ruby-element-in-words-of-one-syllable-or-less" title="Daniel Davis - The HTML5 &lt;ruby&gt; element in words of one syllable or less">The <abbr>HTML</abbr>5 &lt;ruby&gt; element in words of one syllable or less</a> by the unstoppable <a href="http://twitter.com/ourmaninjapan" title="Daniel Davis on Twitter @ourmaninjapan">Daniel Davis</a> of Opera</li>
</ul>
</section>

<section id="feedback">
<h2>Feedback please!</h2>

<p>So what do you think of <code>&lt;ruby&gt;</code> and friends? Let us know in the comments! If you know about the use of annotations like this in other languages, or have used <code>&lt;ruby&gt;</code>, tell us about it too!</p>

<!-- Bonus for source readers…

Questions to Hixie:
* would the expiry date would still be valid
* why was complex ruby dropped? no use case?
* would the WWW abbr-as-ruby would still be valid (what about <ruby><abbr>WWW</abbr><rt>world wide web</rt></ruby>)

Answers:
* HTML5 ruby is basically what IE supports
* complex ruby may return in future if there’s a definite use case for it that can’t be solved by nested ruby
* Hixie thought the non-language uses were a bit dodgy ;-) -->
</section><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><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/video-subtitling-and-webvtt/" rel="bookmark" class="crp_title">Video Subtitling and WebVTT</a></li><li><a href="http://html5doctor.com/review-html5-now-dvd/" rel="bookmark" class="crp_title">Review: HTML5 Now (DVD)</a></li><li><a href="http://html5doctor.com/i-b-em-strong-element/" rel="bookmark" class="crp_title">The i, b, em, &amp; strong elements</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/ruby-rt-rp-element/" rel="bookmark">The ruby element and her hawt friends, rt and rp</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on May 11, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/ruby-rt-rp-element/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>The small &amp; hr elements</title>
		<link>http://html5doctor.com/small-hr-element/</link>
		<comments>http://html5doctor.com/small-hr-element/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 13:58:55 +0000</pubDate>
		<dc:creator>Oli Studholme</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[hr]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[small]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1506</guid>
		<description><![CDATA[<p>Two more HTML4 presentational elements that have undergone transmogrification to have semantics in HTML5 are <code>&#60;small&#62;</code> and <code>&#60;hr&#62;</code></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://html5doctor.com/i-b-em-strong-element/" title="The i, b, em, &amp; strong elements | HTML5 Doctor">We recently examined <code>&lt;i&gt;</code> and <code>&lt;b&gt;</code></a>, presentational HTML4 elements that have been given a new lease on semantic life. Two more elements that have undergone transmogrification to receive semantics in HTML5 are <code>&lt;small&gt;</code> and <code>&lt;hr&gt;</code>:</p>

<ul>
<li><strong><code>&lt;small&gt;</code></strong> — was for smaller text, now used for <em>side comments and small print</em> (<a href="http://dev.w3.org/html5/markup/small.html" title="HTML5: small – small print (CHANGED)">W3C:Markup</a>, <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-small-element" title="4.6 Text-level semantics — HTML5 (including next generation additions still in development)">WHATWG</a>)</li>
<li><strong><code>&lt;hr&gt;</code></strong> — was horizontal rule, now used for <em>a paragraph-level thematic break</em> in text (<a href="http://dev.w3.org/html5/markup/hr.html" title="HTML5: hr – thematic break (CHANGED)">W3C:Markup</a>, <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-hr-element" title="4.5 Grouping content — HTML5 (including next generation additions still in development)">WHATWG</a>)</li>
</ul>

<section id="element-small">
<h2>The <code>&lt;small&gt;</code> element</h2>

<blockquote>
<p>The small element represents so-called “small print” such as legal disclaimers and caveats.</p>
<footer><cite><a href="http://dev.w3.org/html5/markup/small.html" title="HTML5: small &#8211; small print (CHANGED)">W3C specification</a></cite></footer>
</blockquote>

<p><code>&lt;small&gt;</code> is now for <em>side comments</em>, which are the inline equivalent of <a href="http://html5doctor.com/understanding-aside/" title="Understanding aside | HTML5 Doctor"><code>&lt;aside&gt;</code></a> — content which is not the main focus of the page. A common example is inline legalese, such as a copyright statement in a page footer, a disclaimer, or licensing information. It can also be used for attribution. <strong>Don’t use it for block-level content</strong> (paragraphs, lists, etc.), as this would be considered main content.</p>

<figure>
<img src="http://html5doctor.com/wp-content/uploads/2010/03/small-license.png" alt="Using the small element for license information" title="Font license" width="524" height="36" class="alignnone size-full wp-image-1510" />
<figcaption>Using <code>&lt;small class="font-license"&gt;</code> to fulfill the requirements of a font license agreement</figcaption>
</figure>

<figure>
<blockquote><p><code>&lt;small&gt;&lt;a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution Share-alike license&lt;/a&gt;&lt;/small&gt;</code></p></blockquote>
<figcaption>Using <code>&lt;small&gt;</code> around a <a href="http://creativecommons.org/choose/" title="Choose a License">Creative Commons license</a> link with <code>rel="license"</code></figcaption>
</figure>

<p><code>&lt;small&gt;</code> text does not need to be smaller than surrounding text — if all you want is smaller text use CSS instead. Use <code>&lt;small&gt;</code> only on inline content. Finally, <code>&lt;small&gt;</code> doesn’t affect the semantics of <code>&lt;em&gt;</code> or <code>&lt;strong&gt;</code>.</p>
</section>

<section id="element-hr">
<h2>The <code>&lt;hr&gt;</code> element</h2>

<blockquote>
<p>The hr element represents a paragraph-level thematic break.</p>
<footer><cite><a href="http://dev.w3.org/html5/markup/hr.html" title="HTML5: hr — thematic break (CHANGED)">W3C specification</a></cite></footer>
</blockquote>

<p><del datetime="2010-03-31T10:43:57+09:00">The “paragraph-level” bit means between <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/content-models.html#paragraph" title="3.2.5 Content models — HTML5 (including next generation additions still in development)">blocks of text</a>, so it can’t be used to separate sections of a site. Instead, <code>&lt;hr&gt;</code> now separates different topics within a section of prose, or between scenes in a novel.</del> <ins datetime="2010-03-31T11:00:02+09:00">After checking with Hixie I found I misinterpreted the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/content-models.html#paragraph" title="3.2.5 Content models — HTML5 (including next generation additions still in development)">paragraph content model</a> (we regret the error!). I learned <code>&lt;hr&gt;</code> actually means <q cite="http://krijnhoetmer.nl/irc-logs/whatwg/20100331#l-169">end of one section, start of another</q>, which is the same semantically as <code>&lt;/section&gt;&lt;section&gt;</code>. Because elements like <code>&lt;section&gt;</code> already indicate this intrinsically, <code>&lt;hr&gt;</code> is more for thematic breaks, such as separating different topics within a section of prose, or between scenes in a novel. However you can use it anywhere you can use a <code>&lt;p&gt;</code>.</ins> While not widely used these days (given the dull default browser renderings), it can be replaced via CSS with an image:</p>

<figure>
<a href="http://oli.jp/example/speckled-band/"><img src="http://html5doctor.com/wp-content/uploads/2010/03/hr-separator.png" alt="Horizontal rule (hr) separator, replaced using CSS with a background image" title="Horizontal rule separator" width="432" height="228" class="alignnone size-full wp-image-1511" /></a>
<figcaption>Style <code>&lt;hr&gt;</code> by removing borders and adding margins &amp; a background image using CSS. For example;<br />
<code>hr {height: 24px; background: url('flourish.png') no-repeat 50% 50%; margin: 3em 0; border: 0;}</code></figcaption>
</figure>

<p>IE7 and lower live up to reputation by adding a border around the image regardless, but <a href="http://blog.neatlysliced.com/2008/03/hr-image-replacement/" title="HR Image Replacement &rsaquo; Neatly Sliced">this can often be worked around</a>. Alternatively you can just hide it via an IE7-and-lower stylesheet. Use a CSS border or background image on another element instead if the transition is obvious (for example between weblog comments), or the intended use is solely presentational.</p>
<figure>
<a href="http://corkd.com/"><img src="http://html5doctor.com/wp-content/uploads/2010/03/corkd.png" alt="Cork’d title with decorative background image" title="A stylish title on Cork’d (thanks Lindsay!)" width="240" height="60" class="alignnone size-full wp-image-1512" /></a>
<figcaption><a href="http://corkd.com/" title="Cork'd | The new way to review, share and discuss wine.">Cork’d.com</a> uses a decorative CSS background image on titles. This would <strong>not</strong> be a good place to use <code>&lt;hr&gt;</code>.</figcaption>
</figure>
</section>

<section id="summary">
<h2>In summary</h2>
<p>When HTML4 was released, the presentational elements <code>&lt;basefont&gt;</code>, <code>&lt;font&gt;</code>, <code>&lt;s&gt;</code>, <code>&lt;strike&gt;</code>, and <code>&lt;u&gt;</code> were already deprecated in favour of CSS. HTML5 completes this by removing <code>&lt;big&gt;</code> and <code>&lt;tt&gt;</code>.</p>

<p>The remaining HTML4 presentational elements — the long-ignored <code>&lt;small&gt;</code> and <code>&lt;hr&gt;</code> elements (along with <a href="http://html5doctor.com/i-b-em-strong-element/" title="The i, b, em, &amp; strong elements | HTML5 Doctor"><code>&lt;i&gt;</code> and <code>&lt;b&gt;</code> from last week</a>) — have been redefined in HTML5 with useful, media-independent semantics that relate to their typical use. Will <em>you</em> be using them? 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-figure-figcaption-elements/" rel="bookmark" class="crp_title">The figure &#038; figcaption elements</a></li><li><a href="http://html5doctor.com/i-b-em-strong-element/" rel="bookmark" class="crp_title">The i, b, em, &amp; strong elements</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/html-5-reset-stylesheet/" rel="bookmark" class="crp_title">HTML5 Reset Stylesheet</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/small-hr-element/" rel="bookmark">The small &amp; hr elements</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on March 16, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/small-hr-element/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
	</channel>
</rss>

