<?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; Mike Robinson</title>
	<atom:link href="http://html5doctor.com/author/miker/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>Let&#8217;s Talk about Semantics</title>
		<link>http://html5doctor.com/lets-talk-about-semantics/</link>
		<comments>http://html5doctor.com/lets-talk-about-semantics/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 16:51:41 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[Elements]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=4440</guid>
		<description><![CDATA[It's time we had "the talk". I could get you a book or recommend some sites from Dr Mike's special bookmarks folder, but the best way to make sure you get the right idea is to do it myself. I'm talking about HTML semantics. Understanding the thinking behind the naming of elements will help your markup shine.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time we had &#8220;the talk&#8221;. I could get you a book or recommend some sites from Dr Mike&#8217;s special bookmarks folder, but the best way to make sure you get the right idea is to do it myself. I&#8217;m talking about HTML semantics. Understanding the thinking behind the naming of elements will help your markup shine.</p>
<section id="semantics-and-the-web">
<h2>Semantics and the Web <a class="permalink" href="#semantics-and-the-web">#</a></h2>
<p>Semantics are the implied meaning of a subject, like a word or sentence. It aids how humans (and these days, machines) interpret subject matter. On the web, HTML serves both humans and machines, suggesting the purpose of the content enclosed within an HTML tag. Since the dawn of HTML, elements have been revised and adapted based on actual usage on the web, ideally so that authors can navigate markup with ease and create carefully structured documents, and so that machines can infer the context of the wonderful collection of data we humans can read.</p>
<p>Until — and perhaps even after — machines can understand language and all its nuances at the same level as a human, we need HTML to help machines understand what we mean. A computer doesn&#8217;t care if you had pizza for dinner. It likely just wants to know what on earth it should do with that information.</p>
<p>HTML semantics are a nuanced subject, widely debated and easily open to interpretation. Not everyone agrees on the same thing right away, and this is where problems arise.</p>
</section>
<section id="whats-the-point">
<h2>What&#8217;s the point? <a class="permalink" href="#whats-the-point">#</a></h2>
<p>Discussions over the importance of semantics are happening all the time, and every so often there&#8217;s an uproar over specific articles on the subject. <a href="http://twitter.com/divya">Divya Manian</a> caused a stir in her Smashing Magazine article <cite><a href="http://coding.smashingmagazine.com/2011/11/11/our-pointless-pursuit-of-semantic-value/">Our Pointless Pursuit Of Semantic Value</a></cite> in <time datetime="2011-11-11">November 2011</time>, in which she argued we have become too caught up in trying to use HTML5&#8242;s semantics, and that the benefits aren&#8217;t worth it:</p>
<blockquote>
<p>Allow me to paint a picture:</p>
<ol>
<li>You are busy creating a website.</li>
<li>You have a thought, &#8220;Oh, now I have to add an element.&#8221;</li>
<li>Then another thought, &#8220;I feel so guilty adding a <code>div</code>. Div-itis is terrible, I hear.&#8221;</li>
<li>Then, &#8220;I should use something else. The <code>aside</code> element might be appropriate.&#8221;</li>
<li>Three searches and five articles later, you&#8217;re fairly confident that <code>aside</code> is not semantically correct.</li>
<li>You decide on <code>article</code>, because at least it&#8217;s not a <code>div</code>.</li>
<li>You&#8217;ve wasted 40 minutes, with no tangible benefit to show for it.</li>
</ol>
<footer>— <cite><a href="http://coding.smashingmagazine.com/2011/11/11/our-pointless-pursuit-of-semantic-value/" title="Our Pointless Pursuit Of Semantic Value">Divya Manian</a></cite></footer>
</blockquote>
<p>This generated a storm of responses, both positive and negative. In <cite><a href="http://adactio.com/journal/4999/">Pursuing Semantic Value</a></cite> <a href="http://twitter.com/adactio">Jeremy Keith</a> argued that being semantically correct is not fruitless, and he even gave an example of how <code>&lt;section&gt;</code> can be used to adjust a document&#8217;s outline. He concludes:</p>
<blockquote>
<p>But if you can get past the blustery tone and get to the kernel of the article, it’s a fairly straightforward message: don’t get too hung up on semantics to the detriment of other important facets of web development.</p>
<footer>— <cite><a href="http://adactio.com/journal/4999/" title="Pursuing semantic value">Jeremy Keith</a></cite></footer>
</blockquote>
<p>I&#8217;ll admit I&#8217;ve been in a situation where I&#8217;ve dug myself a mind hole, trying to decide which element is &#8220;correct&#8221; and then depressing myself with thoughts of how irrelevant it all seems. What gives me strength is the thought that I&#8217;m not marking this up for me, but for everyone who can benefit from the enhanced meaning. Whether it&#8217;s the browser, a search engine spider, an accessibility tool, the person you pass the project on to, or even future you returning to the project in six months time, the markup indicates how the content should be interpreted. As long as your markup makes sense and isn&#8217;t over the top (e.g., if you just <a href="http://html5doctor.com/avoiding-common-html5-mistakes/#section-wrapper">replace all your HTML 4 <code>&lt;div&gt;</code>s with <code>&lt;section&gt;</code>s</a>, you may be misunderstanding the element or even your content), then don&#8217;t worry so much about it all.</p>
<p>To help you choose the most appropriate element, we released a <a href="http://html5doctor.com/resources/#flowchart">flowchart of HTML5 sectioning elements</a> that you can print off and follow whenever you get stuck. If all else fails, don&#8217;t forget about your old buddy <a href="http://html5doctor.com/you-can-still-use-div/"><code>&lt;div&gt;</code></a>. Then again, maybe you&#8217;ve stumbled across a need for something new&hellip;</p>
<p>  <a href="http://html5doctor.com/resources/#flowchart"><img src="http://html5doctor.com/downloads/h5d-sectioning-flowchart.sml.png" alt="flowchart of HTML5 sectioning elements"></a><br />
</section>
<section id="naming-things">
<h2>Naming Things <a class="permalink" href="#naming-things">#</a></h2>
<p>Of all the possible new element names in HTML5, the spec is pretty set on things like <code>&lt;nav&gt;</code> and <code>&lt;footer&gt;</code>. If you&#8217;ve used either of those as a <code>class</code> or <code>id</code> in your own markup, it&#8217;s no coincidence. Studies of the web from the likes of <a href="http://code.google.com/webstats/">Google</a> and <a href="http://dev.opera.com/articles/view/mama-markup-report-part-2/">Opera</a> (amongst others) looked at which names people were using to hint at the purpose of a part of their HTML documents. The authors of the HTML5 spec recognised that developers needed more semantic elements and looked at what classes and IDs were already being used to convey such meaning.</p>
<p>Of course, it isn&#8217;t possible to use all of the names researched, and of the millions of words in the English language that could have been used, it&#8217;s better to focus on a small subset that meets the demands of the web. Yet some people feel that the spec isn&#8217;t yet doing so.</p>
<section id="what-about-adding-more-elements">
<h3>What about adding more elements? <a class="permalink" href="#what-about-adding-more-elements">#</a></h3>
<figure>
      <img src="http://html5doctor.com/wp-content/uploads/2012/02/why_not_zoidberg.jpg" alt="The character Dr Zoidberg from the TV animation Futurama, with the caption: &lt;article&gt;? Why not &lt;zoidberg&gt;?"><br />
    </figure>
<p>When I first met fellow HTML5 Doctor <a href="http://twitter.com/brucel">Bruce Lawson</a>, I asked him this question: <q>If we have elements like <code>&lt;article&gt;</code>, why don&#8217;t we have one for products of a shop?</q> I understand more about HTML now than I did then, but at the time it seemed like a very logical element to add. Why restrict ourselves to documents with <code>&lt;article&gt;</code>s when the web has evolved beyond that with shops, applications, and games? I&#8217;m sure many of you have felt the same way. Some have even put cases to the WHATWG suggesting more elements like the often requested <code>&lt;comment&gt;</code>.</p>
<p>Recently, editor of the HTML5 spec <a href="http://www.hixie.ch/">Ian Hickson</a> wrote responses to some of these <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-January/034506.html">requests for new elements for comments</a>, explaining why <code>&lt;article&gt;</code> within <code>&lt;article&gt;</code> suffices for marking up comments:</p>
<blockquote>
<p><code>&lt;article&gt;</code> isn&#8217;t just for articles. That&#8217;s the point.</p>
<p>Note that its name is irrelevant here. It could be called <code>&lt;pineapple&gt;</code> — what matters is what it is defined to mean, not what its name is. And its definition is one that covers both articles and comments. They are both self-contained compositions.</p>
<footer>— <cite><a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-January/034506.html" title="Requests for new elements for comments">Ian Hickson</a></cite></footer>
</blockquote>
<p>As much as <a href="https://twitter.com/akamike/status/162466809432379392">I am all for the much needed addition of <code>&lt;pineapple&gt;</code></a>, Ian makes a good case for why we don&#8217;t need <code>&lt;comment&gt;</code> (or similar). Dr Bruce often uses the following analogy when trying to explain <code>&lt;article&gt;</code>:</p>
<blockquote>
<p>Don&#8217;t think of <code>&lt;article&gt;</code> as a magazine article. Think of it as an article of clothing, an independent entity that can be arranged in conjunction with other articles of clothing, but is a complete thing in itself.</p>
</blockquote>
<p>I hear you ask, <q>That&#8217;s all well and good, Mike, but what does understanding <code>&lt;article&gt;</code> have to do with adding new elements?</q> To add something to the spec, you need to:</p>
<ol>
<li>document actual use cases,</li>
<li>show how developers are working around the lack of this feature now, and</li>
<li>make a compelling case for why HTML5 needs it.</li>
</ol>
<p>Step one is to make sure what you&#8217;re asking for can&#8217;t be achieved with what already exists. This is exactly the problem with the proposals for <code>&lt;comment&gt;</code>. Any difference from <code>&lt;article&gt;</code> is so minimal that it isn&#8217;t worth adding.</p>
<aside class="sidenote">
<p>The WHATWG has a <a href="http://www.whatwg.org/mailing-list#specs">mailing list for providing feedback</a> on the spec. To get involved, you need to subscribe, and I recommend checking the <a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/">archives</a> for previous proposals to see if your idea has already been adressed. Not satisfied? Send an email to the list with test cases and evidence as to why your proposal is worth considering.</p>
</aside>
<p>If every proposal for a minor deviation of an existing element was accepted, the spec would be bloated with far more elements than necessary. User agents would have to keep up with the vast array of markup possibilities for a given bit of content — as would you, the author. And think about this: at the end of the day, what are you actually going to use that new element for? <em>Really?</em></p>
<p>That&#8217;s not to say you should be discouraged from putting your ideas forward. Take it as advice on what to look for when you want to contribute something to the spec. It may even help you to think differently about your work. Some problems just need a fresh perspective to help solve them.</p>
</section>
</section>
<section id="stop-worrying">
<h2>HTML5 Doctor, or: How I Learned to Stop Worrying and Love HTML <a class="permalink" href="#stop-worrying">#</a></h2>
<p>Once you learn to look past element names and think of their essential meaning, it gets a bit easier to write markup. Think of your chunks of content in terms of how they relate to each other and in which contexts they can be used. In our <a href="http://html5doctor.com/article-archive/">article archive</a>, we&#8217;ve covered a lot of elements with examples of their use. If you&#8217;re ever in doubt, I highly recommend our <a href="http://html5doctor.com/resources/#flowchart">flowchart of HTML5 sectioning elements</a> to help you along.</p>
<p>Try to keep things simple. Overthinking your markup will only cause more problems than it&#8217;s worth. And let&#8217;s face it: it&#8217;s not like you can&#8217;t change it later!</p>
<p>You may also be interested in adopting <a href="http://microformats.org/">Microformats</a>, something Dr <a href="http://twitter.com/boblet">Oli Studholme</a> has written about here on HTML5 Doctor. <cite><a href="http://html5doctor.com/microformats/">Extending HTML5 — Microformats</a></cite> is recommended reading for those who want to take their markup a bit further. Dr Oli has also looked at <cite><a href="http://html5doctor.com/microdata/">Extending HTML5 with Microdata</a></cite>, which <q cite="http://html5doctor.com/microdata/">gives us a whole new way to add extra semantic information</q>.</p>
<p>Finally, try utilising HTML5 markup in ways that gain the benefit of these new elements. Create tools, use your own documents to test how well-formed and structured they are, and test how portable your content really is. Who knows, you may even find yourself writing a proposal for the next addition to the spec.</p>
<p>Do you know something the web needs that&#8217;s missing from HTML5? 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/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/happy-1st-birthday-us/" rel="bookmark" class="crp_title">Happy 1st Birthday us</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/your-questions-18/" rel="bookmark" class="crp_title">Your Questions 18</a></li>
<li><a href="http://html5doctor.com/outlines/" rel="bookmark" class="crp_title">Document Outlines</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/lets-talk-about-semantics/" rel="bookmark">Let&#8217;s Talk about Semantics</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on April 18, 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/lets-talk-about-semantics/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>HTML5 Doctor Drop-In Clinic</title>
		<link>http://html5doctor.com/html5-doctor-drop-in-clinic/</link>
		<comments>http://html5doctor.com/html5-doctor-drop-in-clinic/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 14:41:39 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[freenode]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[WHATWG]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=4430</guid>
		<description><![CDATA[<p>Got an itch? A problem that's slowing you down? Need someone to answer your question? If email just doesn't quite patch you up, you should stop by the HTML5 Doctor <abbr title="Internet Relay Chat">IRC</abbr> channel.</p>]]></description>
			<content:encoded><![CDATA[<p>Got an itch? A problem that&#8217;s slowing you down? Need someone to answer your question? If email just doesn&#8217;t quite patch you up, you should stop by the HTML5 Doctor <abbr title="Internet Relay Chat">IRC</abbr> channel.</p>
<p>Originally set up by <a href="http://twitter.com/rem">Remy</a>, the <a href="http://en.wikipedia.org/wiki/Internet_Relay_Chat">IRC</a> channel is there for brief questions about all things HTML5. If one of the HTML5 Doctors is around, we can try to help you, or if you don&#8217;t have a question, you&#8217;re more than welcome to idle and talk with the <abbr title="HTML5 Doctor">H5D</abbr> community.</p>
<p>For those who don&#8217;t know what IRC is, it&#8217;s a protocol for chat that&#8217;s been around almost as long as I have! No matter what <abbr title="Operating System">OS</abbr> you use, you should be able to find an IRC client to get connected. There are even web-based services like <a href="http://webchat.freenode.net/?channels=html5doctor">Freenode&#8217;s own web IRC</a> and <a href="http://irccloud.com/">IRC Cloud</a>, so you can jump on no matter where you are with nothing to install. The Mibbit wiki has an <a href="http://wiki.mibbit.com/index.php/IRC_tutorial">IRC tutorial</a> to help get you using IRC, and Freenode hosts a guide to <a href="http://freenode.net/using_the_network.shtml">using the network</a>.</p>
<p>When you&#8217;re ready, the channel can be found at <a href="irc://irc.freenode.net/html5doctor">#html5doctor</a> on <a href="http://freenode.net/">Freenode</a> (irc.freenode.net). Once you&#8217;re connected and you&#8217;ve joined the channel, say hi and see who&#8217;s around. If no one is there, stick around, and maybe check out other channels on Freenode such as the WHATWG channel, <a href="irc://irc.freenode.org/whatwg">#whatwg</a>.</p>
<p>The only thing to keep in mind is that we HTML5 Doctors do this voluntarily with jobs and lives to run. We can&#8217;t be there 24/7. When we are available to answer questions, we&#8217;ll try to address whomever we can, and maybe another idling patient will be able to lend a hand.</p>
<p>For more extensive problems, or if you also don&#8217;t have time to hang around on IRC, check our <a href="http://html5doctor.com/article-archive/">article archive</a> or drop us an email through <a href="http://html5doctor.com/ask-the-doctor/">Ask the HTML5 Doctor</a> if you can&#8217;t find your answer there.</p>
<p>Drop on by, hang out, and feel free to talk all about HTML5 and the wonderful web.</p>
<p>And please, no medical questions!
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/2022-or-when-will-html-5-be-ready/" rel="bookmark" class="crp_title">2022, or when will HTML 5 be ready?</a></li>
<li><a href="http://html5doctor.com/dd-details-wrong-again/" rel="bookmark" class="crp_title">dd-details wrong again</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-2/" rel="bookmark" class="crp_title">Your questions answered #2</a></li>
<li><a href="http://html5doctor.com/u-element/" rel="bookmark" class="crp_title">The return of the u element</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-1/" rel="bookmark" class="crp_title">Your questions answered #1</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/html5-doctor-drop-in-clinic/" rel="bookmark">HTML5 Doctor Drop-In Clinic</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on February 16, 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/html5-doctor-drop-in-clinic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pushing and Popping with the History API</title>
		<link>http://html5doctor.com/history-api/</link>
		<comments>http://html5doctor.com/history-api/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 13:09:47 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[JavaScript APIs]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3897</guid>
		<description><![CDATA[Until recently, we developers couldn’t to do much with the state and history of the browser. We could check the number of items in the history and push users forwards and backwards, but this provides little benefit to the user. With the rise of more dynamic web pages, we need more control. Thankfully, HTML5 gives [...]]]></description>
			<content:encoded><![CDATA[<p>Until recently, we developers couldn’t to do much with the state and history of the browser. We could check the number of items in the history and push users forwards and backwards, but this provides little benefit to the user. With the rise of more dynamic web pages, we need more control. Thankfully, HTML5 gives us that control by extending the JavaScript History API.</p>
<section id="the-point">
<h2>What’s the point? <a class="permalink" href="#the-point">#</a></h2>
<p>It goes without saying that URLs are important. They’re <em>the</em> method of accessing the vast collections of information and resources on the web, and more recently, they’ve begun representing the intended state of a web application. You can copy these URLs and share them with your friends or use them to create links from any HTML document. They’re the veins of the web, and they need to be looked after.</p>
<p>Previously, the JavaScript History API offered some very simple functionality:</p>
<pre><code>// Check the length of the history stack
console.log(history.length);

// Send the user agent forward
console.log(history.forward());

// Send the user agent back
console.log(history.back());

// Send the user agent back (negative) or forward (positive)
// by a given number of items
console.log(history.go(-3));
</code></pre>
<p>With dynamic Ajax web applications, where the browser updates the page in parts instead of changing location entirely, it’s difficult to give the user a URL to bookmark or share the current application state. <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#the-id-attribute">Fragment identifiers</a>, like those used on this article’s headings via the <code>id</code> attribute, provide some state information, but they’re entirely dependent on client-side scripts.</p>
<p>The changes to the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html">History API</a> are intended to give developers ways to push history items to the browser so the native back and forward actions can cycle through those items. These history items can also hold data that you can later extract to restore the page state.</p>
<blockquote>
<p>Pages can <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#dom-history-pushstate" title="dom-history-pushState">add</a> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#state-object" title="state object">state objects</a> between their entry in the session history and the next (“forward”) entry. These are then <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-popstate" title="event-popstate">returned to the script</a> when the user (or script) goes back in the history, thus enabling authors to use the “navigation” metaphor even in one-page applications.</p>
<footer>- <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html" title="6.4 Session history and navigation">WHATWG</a></cite></footer>
</blockquote>
<p>If the user copies or bookmarks a stateful URL and visits it later, your back-end can be configured to interpret such a URL and jump the user right to the correct page and/or state.</p>
<p>In this article, I’ll cover the client-side use of the History API, so make sure you set up your server to work with the new URLs. If you’ve already built an accessible website that provide these entry points, you’re laughing!</p>
<section id="those-fking-hashbangs">
<h4>Those <em>f#!king</em> hashbangs… <a class="permalink" href="#those-fking-hashbangs">#</a></h4>
<p>You may have already seen articles fussing over the adoption of the “hashbang” (#!) pattern on sites like <a href="http://twitter.com">Twitter</a>. This technique updates the address bar with a fragment identifier that can then be used by JavaScript to determine which page and state should be displayed.</p>
<p>This works as a method of creating a bookmarkable, shareable URL for a page’s state in the absense of a standard API. While the Twitter implementation accepts both <code>http://twitter.com/#!/akamike</code> and <code>http://twitter.com/akamike</code>, it has some disadvantages:</p>
<ul>
<li>The fragment identifier is only accessible on the client side. This means that only JavaScript can utilise it, so browsers without JavaScript enabled are out of luck.</li>
<li>As the server does not receive the path following the hashbang, removing that JavaScript drops support for all those URLs. That’s a lot of broken links, so you’re stuck with that JavaScript <em>forever</em>.</li>
<li>It’s ugly. It’s a hack and it looks like one.</li>
</ul>
<p>The hashbang was never intended to be a long-term solution, so don’t rely on it. If you do use hashbangs, be prepared to deal with the consequences (and possible backlash from web purists).</p>
</section>
</section>
<section id="making-history">
<h2>Making History <a class="permalink" href="#making-history">#</a></h2>
<p>These examples will build on top of each other. We’ll start with a <a href="http://html5doctor.com/wp-content/uploads/2011/10/history_base.html">basic HTML document</a> with some inline styles and scripts for your convenience.</p>
<aside class="sidenote">
<p>For a simple HTTP server, open the command line, <code>cd</code> to the directory you would like to serve, run <code>python -m SimpleHTTPServer 8080</code>, then open <code>localhost:8080</code> in your browser. Alternatively, try a bundled setup like <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> or <a href="http://www.mamp.info/en/index.html">MAMP</a>.</p>
</aside>
<p>Save this file and open it in your favourite editor. It must be accessed via HTTP, so that means you need either a local server (e.g. <code>http://localhost/</code>) or an online web server you can upload to. <strong>Viewing the file directly using your browser’s Open File function will not work</strong>, since it uses the <code>file://</code> protocol and not HTTP. Also be sure to update the <code>href</code> attributes on each of the navigation links to ensure the correct directory structure is used. Personally, I’m viewing the demo locally at <code>http://localhost/history</code>.</p>
<p>We’ll be working exclusively within the <code>&lt;script&gt;</code> element at the end of the <code>&lt;body&gt;</code>. The code includes some simple styles and dynamically changes the content as you click the links. In reality, this could be loaded from your server via <code>XMLHttpRequest</code>, but for the purposes of this demonstration I’ve bundled it up into a self-contained file. The important part is that we have a quick-and-dirty dynamic page to work with, so let the fun begin!</p>
<p>At the moment there, is no bookmarkable URL for the different states of this page. If you click around the navigation items, then click Back in your browser, you won’t be taken back to the previous state and may even be taken away from the page to whatever you viewed before (depending on your browser). It would be nice if you could share “Socks” with your friends, right? We can do that via <code>history.pushState()</code>.</p>
<p>The <code>history.pushState()</code> method takes three parameters:</p>
<dl>
<dt><code>data</code></dt>
<dd>Some structured data, such as settings or content, assigned to the history item.</dd>
<dt><code>title</code></dt>
<dd>The name of the item in the history drop-down shown by the browser’s back and forward buttons. (Note: this is not currently supported by any major browsers.)</dd>
<dt><code>url</code> <em>(optional)</em></dt>
<dd>The URL to this state that should be displayed in the address bar.</dd>
</dl>
<p>With these parameters, you can define the state of the page, give that state a name, and even provide a bookmarkable address, as if the page had reloaded entirely. Let’s dive right in and add this to the <code>clickHandler</code> function, right above the <code>return</code> statement:</p>
<figure>
<pre><code>function clickHandler(e) {
  /* Snip... */

  // Add an item to the history log
  history.pushState(data, event.target.textContent, event.target.href);

  return event.preventDefault();
}
</code></pre>
</figure>
<p>The single line of code we added informs the <code>history</code> object that:</p>
<ul>
<li>we want to add an item to the log,</li>
<li>it should remember the data that we’ve already loaded,</li>
<li>it should assign a name to this state based on the text of the link we clicked (even though this isn’t used — it’s good to get into the habit of recording a name for the state), and</li>
<li>it should update the address bar with the <code>href</code> attribute of that link.</li>
</ul>
<p>Reload the page in your browser and click a few of the links, keeping an eye on the address bar. Notice how it changes on each click, despite the fact that you aren’t actually navigating away from this page. If you also have a look at your history log, you’ll see a long list of page titles (in this case ”Kittens!” over and over). Provided your server is set up to serve the correct page upon access, the user could copy that URL and paste it into a new browser window to jump straight to that kitten.</p>
<p>At the moment, clicking the back button will pop you through the history items, but the page won’t react to these changes. That&#8217;s because so far, we’ve only created the history records. How can we allow active users to return to a previous state? We listen to the <code>popstate</code> event.</p>
</section>
<section id="historical-events">
<h2>Historical Events in Navigation <a class="permalink" href="#historical-events">#</a></h2>
<p>The user agent fires a <code>popstate</code> event when the user navigates through their history, whether backwards or forwards, provided it isn’t taking the user away from the current page. That is, all those <code>pushState</code>s we called will keep the user on the current page, so the <code>popstate</code> event will fire for each history item they pop through.</p>
<p>Before the closing <code>&lt;/script&gt;</code> tag, add a new listener for the <code>popstate</code> event:</p>
<figure>
<pre><code>// Revert to a previously saved state
window.addEventListener('popstate', function(event) {
  console.log('popstate fired!');

  updateContent(event.state);
});
</code></pre>
</figure>
<p>We attach the event listener to the <code>window</code>, which is responsible for firing the event, and pass this event into our handler. We log a message (so we can see when this event is firing), and then we update the content using the state we saved previously. The state is attached to the <code>event</code> object via the <code>state</code> property.</p>
<p>Open up the page fresh in your browser, click around like before, and then click back. As before, the URL in the address bar changes as you cycle through states, but now the content is also restored back to what it should be. Click forward, and the content is likewise correctly restored.</p>
<div class="callout warning-block">
<p>If you look at the developer console in Chrome when you load the page for the first time, you’ll see the <code>popstate</code> event fired immediately, before you’ve even clicked a link. This is because Chrome considers the initial page load to be a change in state, and so it fires the event. In this instance, the <code>state</code> property is <code>null</code>, but thankfully the <code>updateContent</code> function deals with this. Keep this in mind when developing as it could catch you out, especially if other browsers assume this behavior.</p>
</p></div>
</section>
<section id="rewriting-history">
<h2>Rewriting history <a class="permalink" href="#rewriting-history">#</a></h2>
<p>Unfortunately, as fantastic as HTML5 is, it doesn’t allow us actual time travel. If it did, I would be going back to my childhood and telling a younger me, “Yes, you should have a slice of cake”. Take that as you will.</p>
<p>The History API does, however, allow us to make amends to our history log items. For example, we could update the current state in response to fresh user input in a form. We can do this with <code>history.replaceState</code>.</p>
<p><code>replaceState</code> works just as <code>pushState</code> does, with the exact same parameters, except that it updates the current entry instead of adding a new one. I can think of one situation in our demo where this could be used: the initial page load. If you click back for long enough, you’ll find that going back to the original URL doesn’t provide you the original content. Let’s fix that by adding the following to the bottom of our script:</p>
<figure>
<pre><code>// Store the initial content so we can revisit it later
history.replaceState({
  content: contentEl.textContent,
  photo: photoEl.src
}, document.title, document.location.href);
</code></pre>
</figure>
<p>As this runs when the page loads, it saves the initial page state. We can later load this state when the user browses back to this point via the event listener we set up previously. You can try it out by loading up the page, clicking a few links, and then hitting back until you return to the original URL. The initial content has returned!</p>
</section>
<section id="demo">
<h2>Demo <a class="permalink" href="#demo">#</a></h2>
<p>I’ve set up a demo of our completed code. I’ve also added a little back-end magic to make our <code>history.pushState</code> URLs work like a real site. Remember that the URLs you push should be live URLs that the user can bookmark and share as real entry points to your site.</p>
<p class="btn half"><a href="http://html5doctor.com/demos/history/">View the History API demo</a></p>
</section>
<section id="browser-support">
<h2>Browser support <a class="permalink" href="#browser-support">#</a></h2>
<p>Up-to-date copies of Chrome (5+), Safari (5.0+), Firefox (4.0+), and Opera (11.50+) have support for the new History API. Even some mobile browsers work just fine, like Mobile Safari on iOS 4+. Unfortunately, IE 9 and below lack support, but it <a href="http://msdn.microsoft.com/en-us/ie/hh272905.aspx#_HTML5History">should work in IE 10</a> when it arrives.</p>
<p>Safari 5.0 sometimes exhibits one oddity: navigating between states causes the loading spinner to appear and stay even when the state has been loaded. This stops when you navigate away using a link or action that does not involve a state saved by the History API.</p>
<section id="polyfill">
<h3>Polyfill <a class="permalink" href="#polyfill">#</a></h3>
<p>A polyfill does exist for the History API. The aptly named <a href="https://github.com/balupton/history.js">History.js</a> uses HTML4’s <code>hashchange</code> event with document fragment identifiers to mimic the history API in older browsers. If one of the hash URLs is used by a modern browser, it uses <code>replaceState</code> to quietly correct the URL.</p>
<p>It sounds like magic, but make sure you’re aware of the consequences of using fragment identifiers, as mentioned previously in this article. As such, the author of History.js has put together a guide titled <a href="https://github.com/balupton/history.js/wiki/Intelligent-State-Handling">Intelligent State Handling</a>.</p>
</section>
</section>
<section id="closing">
<h2>Closing thoughts <a class="permalink" href="#closing">#</a></h2>
<p>URLs go beyond just the browsing session of a user. They’re historically important markers for resources that could very well remain in use for many years to come. Before you embark on developing your site’s JavaScript, you should give thought to the <a href="http://warpspire.com/posts/url-design/">design of your URLs</a>. Make them meaningful and organised. Make sure you can directly access them without JavaScript. Only then should you add your JavaScript to enhance the browsing experience.</p>
</section>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<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/drag-and-drop-to-server/" rel="bookmark" class="crp_title">Drag and Drop and Automatically Send to the Server</a></li>
<li><a href="http://html5doctor.com/how-to-get-all-the-browsers-playing-ball/" rel="bookmark" class="crp_title">How to get all the browsers playing ball</a></li>
<li><a href="http://html5doctor.com/methods-of-communication/" rel="bookmark" class="crp_title">Methods of communication</a></li>
<li><a href="http://html5doctor.com/storing-data-the-simple-html5-way-and-a-few-tricks-you-might-not-have-known/" rel="bookmark" class="crp_title">Storing Data the Simple HTML5 Way (and a few tricks you might not have known)</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/history-api/" rel="bookmark">Pushing and Popping with the History API</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on November 15, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/history-api/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Document Outlines</title>
		<link>http://html5doctor.com/outlines/</link>
		<comments>http://html5doctor.com/outlines/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 14:57:06 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[Structure]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[outline]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3433</guid>
		<description><![CDATA[<p>Document outlines have changed a bit in HTML5. For a start, they’re actually in the spec! The HTML5 Doctor is here to explain what document outlines are, how to make good ones, and why you should care.</p>]]></description>
			<content:encoded><![CDATA[<p>Document outlines have changed a bit in HTML5. For a start, they’re actually in the spec! The HTML5 Doctor is here to explain what document outlines are, how to make good ones, and why you should care.</p>

<section id="what-are-outlines">
  <h2>What are document outlines? <a class="permalink" href="#what-are-outlines">#</a></h2>
  
  <p>The document outline is the structure of a document, generated by the document’s headings, form titles, table titles, and any other appropriate landmarks to <a href="http://www.w3.org/TR/2002/REC-UAAG10-20021217/guidelines#tech-provide-outline-view">map out the document</a>. The user agent can apply this information to generate a table of contents, for example. This table of contents could then be used by assistive technology to help the user, or be parsed by a machine like a search engine to improve search results.</p>
  
  <p>The outlining algorithm has been clearly defined in the <a href="http://dev.w3.org/html5/spec/Overview.html#outlines">HTML5 spec</a>, so once all browsers and assistive technologies play ball, there will be some major accessibility wins (more on <a href="#real-world-outlines">support</a> later). Before we take a look at how this new algorithm works, it’s time for a quick walk down memory lane.</p>
</section>

<section id="outlines-in-html4">
  <h2>Outlines in HTML4 <a class="permalink" href="#outlines-in-html4">#</a></h2>
  
  <p>Creating document outlines prior to HTML5 was simple. You had six heading elements, <code>&lt;h1&gt;</code> through <code>&lt;h6&gt;</code>. Lower-numbered headings were of a higher rank of higher-numbered ones — i.e. <code>&lt;h1&gt;</code> was ranked higher than <code>&lt;h2&gt;</code>:</p>

  <pre><code>&lt;h1&gt;My fantastic site&lt;/h1&gt;
&lt;h2&gt;About me&lt;/h2&gt;
&lt;p&gt;I am a man who lives a fascinating life. Oh the stories I could tell you...&lt;/p&gt;
&lt;h3&gt;What I do for a living&lt;/h3&gt;
&lt;p&gt;I sell enterprise-managed ant farms.&lt;/p&gt;
&lt;h2&gt;Contact&lt;/h2&gt;
&lt;p&gt;Shout my name and I will come to you.&lt;/p&gt;
</code></pre>

  <p>This example would produce the following outline:</p>
  <div class="callout">
  <ol>
    <li>
      My fantastic site
      <ol>
        <li>
          About me
          <ol>
            <li>What I do for a living</li>
          </ol>
        </li>
        <li>Contact</li>
      </ol>
    </li>
  </ol>
</div>

  <p>The <code>&lt;h2&gt;</code> titles are children of the <code>&lt;h1&gt;</code>, and the &#8220;About me&#8221; content has a further sub-heading using an <code>&lt;h3&gt;</code>. It’s simple but restrictive, as you have to ensure the heading levels are appropriate for the intended structure, and you’re limited to six levels. The latter restriction is usually not such a problem, but it still exists for all you heading fanatics (oh you guys!).</p>

  <p>HTML5 does this as well. The above example would produce the same outline, but it can be taken even further using the new sectioning elements.</p>
</section>

<section id="sectioning-elements">
  <h2>Sectioning elements <a class="permalink" href="#sectioning-elements">#</a></h2>
  
  <p>The concepts behind HTML5 document outlines are actually older than you might think! Tim Berners-Lee posted to the www-talk mailing list <a href="http://lists.w3.org/Archives/Public/www-talk/1991SepOct/0003.html">back in 1991</a> (props to <a href="http://html5doctor.com/author/olib/">Dr Oli</a> for digging that up), suggesting something quite close to what is demonstrated in this article.</p>

  <p>The sectioning elements <a href="/section/"><code>&lt;section&gt;</code></a>, <a href="/article/"><code>&lt;article&gt;</code></a>, <a href="/aside/"><code>&lt;aside&gt;</code></a> and <a href="/nav/"><code>&lt;nav&gt;</code></a> can all help to create a more logical structure in the document outline. Let&#8217;s go crazy and rewrite our previous example using only <code>&lt;h1&gt;</code> elements for headings:</p>

  <pre><code>&lt;h1&gt;My fantastic site&lt;/h1&gt;
&lt;h1&gt;About me&lt;/h1&gt;
&lt;p&gt;I am a man who lives a fascinating life. Oh the stories I could tell you...&lt;/p&gt;
&lt;h1&gt;What I do for a living&lt;/h1&gt;
&lt;p&gt;I sell enterprise-managed ant farms.&lt;/p&gt;
&lt;h1&gt;Contact&lt;/h1&gt;
&lt;p&gt;Shout my name and I will come to you.&lt;/p&gt;
</code></pre>

  <p>The outline would now look like this:</p>
<div class="callout">
  <ol>
    <li>My fantastic site</li>
    <li>About me</li>
    <li>What I do for a living</li>
    <li>Contact</li>
  </ol>
</div>
  <p>Clearly, that’s no good — we&#8217;ve lost our structure! With sectioning elements, we can make it look like before without changing those headings. In this particular example, I think <code>&lt;section&gt;</code> is most appropriate:</p>

  <pre><code>&lt;h1&gt;My fantastic site&lt;/h1&gt;
&lt;section&gt;
  &lt;h1&gt;About me&lt;/h1&gt;
  &lt;p&gt;I am a man who lives a fascinating life. Oh the stories I could tell you...&lt;/p&gt;
  &lt;section&gt;
    &lt;h1&gt;What I do for a living&lt;/h1&gt;
    &lt;p&gt;I sell enterprise-managed ant farms.&lt;/p&gt;
  &lt;/section&gt;
&lt;/section&gt;
&lt;section&gt;
  &lt;h1&gt;Contact&lt;/h1&gt;
  &lt;p&gt;Shout my name and I will come to you.&lt;/p&gt;
&lt;/section&gt;
</code></pre>

  <p>Run it through the outliner and we’re back to normal:</p>
<div class="callout">
  <ol>
    <li>
      My fantastic site
      <ol>
        <li>
          About me
          <ol>
            <li>What I do for a living</li>
          </ol>
        </li>
        <li>Contact</li>
      </ol>
    </li>
  </ol>
</div>
  <p>But why? The sectioning elements act quite literally as their name suggests: <em>they define sections of the parent element</em>. These sections can be thought of as child nodes whose headings fall under their parent heading, regardless of their rank. The following example illustrates this further:</p>

  <pre><code>&lt;h2&gt;HTML5 Doctor articles&lt;/h2&gt;
&lt;article&gt;
  &lt;h1&gt;The section element&lt;/h1&gt;
  &lt;p&gt;We doctors are a bunch of chums using HTML5 and writing about how we do it...&lt;/p&gt;
&lt;/article&gt;
&lt;article&gt;
  &lt;h1&gt;The article element&lt;/h1&gt;
  &lt;p&gt;We’ve discussed a lot of new elements here at HTML5Doctor...&lt;/p&gt;
&lt;/article&gt;
</code></pre>

  <p>Even though the articles contain <code>&lt;h1&gt;</code>s, this produces the following outline: </p>

<div class="callout">
  <ol>
    <li>
      HTML5 Doctor articles
      <ol>
        <li>The section element</li>
        <li>The article element</li>
      </ol>
    </li>
  </ol>
</div>  

  <p>Equally, owing to how the outliner works, the following examples
(while probably not the best use of headings) produce the exact same above outline:</p>
  
    <figure>
      <pre><code>&lt;h1&gt;HTML5 Doctor articles&lt;/h1&gt;
&lt;article&gt;
  &lt;h3&gt;The section element&lt;/h3&gt;
&lt;/article&gt;
&lt;article&gt;
  &lt;h3&gt;The article element&lt;/h3&gt;
&lt;/article&gt;
</code></pre>
    </figure>
  
  <figure>
    <pre><code>&lt;h2&gt;HTML5 Doctor articles&lt;/h2&gt;
&lt;article&gt;
  &lt;h2&gt;The section element&lt;/h2&gt;
&lt;/article&gt;
&lt;article&gt;
  &lt;h2&gt;The article element&lt;/h2&gt;
&lt;/article&gt;
</code></pre>
  </figure>

  <figure>
    <pre><code>&lt;h6&gt;HTML5 Doctor articles&lt;/h6&gt;
&lt;article&gt;
  &lt;h1&gt;The section element&lt;/h1&gt;
&lt;/article&gt;
&lt;article&gt;
  &lt;h1&gt;The article element&lt;/h1&gt;
&lt;/article&gt;
</code></pre>
  </figure>
  
  <p>When choosing which heading to use in your documents, <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/sections.html#headings-and-sections">the spec</a> has recommendations:</p>

<blockquote cite="http://www.whatwg.org/specs/web-apps/current-work/complete/sections.html#headings-and-sections">
<p>Sections may contain headings of any rank, but authors are strongly encouraged to either use only h1 elements, or to use elements of the appropriate rank for the section’s nesting level.</p>
<footer>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/complete/sections.html#headings-and-sections" title="4.4.11 Headings and sections">WHATWG HTML5 specification</a></cite></footer></blockquote>

  <p>You should also make sure you’re aware of how differently ranked headings work when used as direct children of a sectioning element. It&#8217;s how it worked prior to HTML5:</p>

  <blockquote cite="http://www.whatwg.org/specs/web-apps/current-work/complete/sections.html#headings-and-sections"><p>The first element of heading content in an element of sectioning content represents the heading for that section. Subsequent headings of equal or higher rank start new (implied) sections, headings of lower rank start implied subsections that are part of the previous one. In both cases, the element represents the heading of the implied section.</p>
<footer>— <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/complete/sections.html#headings-and-sections" title="4.4.11 Headings and sections">WHATWG HTML5 specification</a></cite></footer></blockquote>

  <section id="untitled-sections">
    <h3>Untitled sections <a class="permalink" href="#untitled-sections">#</a></h3>

    <p>Sectioning elements that do not contain a child heading will be labelled as “Untitled”, indicating the lack of a logical heading but preserving the outline as in the example below:</p>
    
    <figure>
      <pre><code>&lt;aside&gt;
  &lt;section&gt;
    &lt;h2&gt;Twitter&lt;/h2&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h2&gt;Recent comments&lt;/h2&gt;
  &lt;/section&gt;
&lt;/aside&gt;
</code></pre>
    </figure>
    
    <p>Running this through the outliner produces this outline:</p>
    <div class="callout">
    <ol>
      <li>
        Untitled <code>aside</code>
        <ol>
          <li>Twitter</li>
          <li>Recent comments</li>
        </ol>
      </li>
    </ol>
    </div>
    
    <p>The outliner has taken the liberty of flagging the sectioning element as untitled, to act as a warning and to preserve a logical structure. For accessibility reasons, we recommend each sectioning element have a heading, even <code>&lt;aside&gt;</code> and <code>&lt;nav&gt;</code>, as shown below. If you don’t want these headings to be visible, you can always hide them with CSS.</p>

    <figure>
      <pre><code>&lt;aside&gt;
  &lt;h1&gt;What you're saying&lt;/h1&gt;
  &lt;section&gt;
    &lt;h2&gt;Twitter&lt;/h2&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h2&gt;Recent comments&lt;/h2&gt;
  &lt;/section&gt;
&lt;/aside&gt;
</code></pre>
    </figure>

<p>Remember, elements like <code>&lt;section&gt;</code> should not be used arbitrarily. See our <a href="http://html5doctor.com/the-section-element/">section article</a> for more.</p>
  </section>
</section>

<section id="using-hgroup">
  <h2>How does <code>&lt;hgroup&gt;</code> affect the outline? <a class="permalink" href="#using-hgroup">#</a></h2>
  
  <p>As Dr Richard Clark said in <a href="http://html5doctor.com/the-hgroup-element/">our <code>&lt;hgroup&gt;</code> article</a>, <code>&lt;hgroup&gt;</code> is <q cite="http://html5doctor.com/the-hgroup-element/">all about the document outline</q>. The outliner will disregard all headings within <code>&lt;hgroup&gt;</code> except the one with the highest ranking. For example, if an <code>&lt;hgroup&gt;</code> contains an <code>&lt;h2&gt;</code>, an <code>&lt;h3&gt;</code> and an <code>&lt;h4&gt;</code>, only the <code>&lt;h2&gt;</code>’s text will be used as the section title in the outline. For example, the following markup:</p>

<pre><code>&lt;article&gt;
  &lt;hgroup&gt;
    &lt;h1&gt;Title goes here&lt;/h1&gt;
    &lt;h2&gt;Subtitle of article&lt;/h2&gt;
  &lt;/hgroup&gt;
  &lt;p&gt;Lorem Ipsum dolor set amet&lt;/p&gt;
&lt;/article&gt;</code></pre>

<p>Would produce the following outline.</p>

    <div class="callout">
    <ol>
      <li>Title goes here</li>
    </ol>
    </div>

  <p>At the time of writing, <code>&lt;hgroup&gt;</code>&#8217;s future is a little uncertain. It was recently <a href="http://html5doctor.com/the-hgroup-hokey-cokey/">removed and then returned</a> to the HTML5 spec, and there are <a href="http://www.w3.org/html/wg/wiki/ChangeProposals/dropHgroup">proposals</a> for its removal or replacement with an alternative. We&#8217;ll be sure to keep HTML5 Doctor up-to-date with any changes as they unfold.</p>
</section>

<section id="sectioning-roots">
  <h2>Sectioning roots <a class="permalink" href="#sectioning-roots">#</a></h2>
  
  <p>Sectioning roots, introduced in HTML5, isolate certain parts of a document to their own separate outlines. Headings within these elements will not show up in the main outline, where the sectioning root element is the <code>&lt;body&gt;</code>.</p>

  <p>The other sectioning root elements are <code>&lt;blockquote&gt;</code>, <code>&lt;figure&gt;</code>, <code>&lt;details&gt;</code>, <code>&lt;fieldset&gt;</code>, and <code>&lt;td&gt;</code>. Each one of these elements is a descendant of the <code>&lt;body&gt;</code> element, but its headings are removed from the top-level outline, instead starting its own isolated outline.</p>
  
  <figure>
    <pre><code>&lt;h1&gt;Top of the outline&lt;/h1&gt;

&lt;section&gt;
  &lt;h2&gt;A heading in the outline&lt;/h2&gt;
  &lt;p&gt;Lorem ipsum dolor sit amet...&lt;/p&gt;
&lt;/section&gt;
&lt;section&gt;
  &lt;h2&gt;Another heading in the outline&lt;/h2&gt;
  &lt;p&gt;Lorem ipsum dolor sit amet...&lt;/p&gt;
  &lt;blockquote&gt;
    &lt;h1&gt;This quoted heading will not appear in the outline&lt;/h1&gt;
    &lt;p&gt;Lorem ipsum dolor sit amet...&lt;/p&gt;
  &lt;/blockquote&gt;
&lt;/section&gt;
</code></pre>
  </figure>
  
  <p>This results in the following outline. Notice that it lacks the <code>&lt;blockquote&gt;</code>’s heading, which has been isolated:</p>
<div class="callout">
  <ol>
    <li>
      Top of the outline
      <ol>
        <li>A heading in the outline</li>
        <li>Another heading in the outline</li>
      </ol>
    </li>
  </ol>
</div>
</section>

<section id="real-world-outlines">
  <h2>Outlines in the real world <a class="permalink" href="#real-world-outlines">#</a></h2>
    
  <p>Unfortunately, there is little support for the new outlining algorithms right now. Search engines may be experimenting with it in their crawling algorithms as you read this, but as far as we know, headings are treated just as they were before. You won’t be penalised for using them, even if you use <a href="http://www.youtube.com/watch?v=GIn5qJKU8VM">multiple <code>&lt;h1&gt;</code>s</a> (which have always been okay as far as the spec is concerned). Check out our <a href="http://html5doctor.com/html5-seo-search-engine-optimisation/">HTML5 and Search Engine Optimisation</a> article for more on search engines and HTML5.</p>
  
  <p>At the time of writing, screen readers do not support these new outlines, so if you do use multiple <code>&lt;h1&gt;</code>s in your documents, it may confuse your users. It’s best if you use logical heading levels — <code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code> — at least until the new outlines are more widely supported.</p>

  <p>As for browsers, both recent releases of Firefox and Chrome have a user agent styles that support HTML5 document outlines. Try this <a href="http://jsbin.com/ijixib">bare-bones example</a> in the latest Chrome or Firefox.</p>
</section>

<section id="conclusion">
  <h2>Final thoughts <a class="permalink" href="#conclusion">#</a></h2>
  
  <p>Despite the spotty support, it’s definitely worth thinking carefully about your document outlines so you’re prepared for the future, and tune in here for news of improved support.</p>
  
  <p>Get to grips with the sectioning elements and sectioning roots and how each affects the outline. When marking up a new site, consider how you could take advantage of the new document outline algorithm. As user agent support strengthens, pages you made with your new-found knowledge of document outlines will be more accessible. Let us know what you think in the comments below!</p>
  
  <section id="outliners">
    <h3>Outliner tools <a class="permalink" href="#outliners">#</a></h3>

    <p>In order to test your outlines, you’ll need an outliner. Here are a few options to get you started:</p>
    
    <ul>
      <li><a href="http://code.google.com/p/h5o/">h5o</a>, a Javascript implementation of the outliner, available as a bookmarklet, extension, or minified JavaScript file</li>
      <li><a href="https://addons.opera.com/addons/extensions/details/html5-outliner/1.0/">An Opera extension</a></li>
      <li><a href="http://gsnedders.html5.org/outliner/">An online outliner</a> where you can upload a file or submit a URL or HTML source to parse (may no longer be under development)</li>
    </ul>
  </section>
</section><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/the-hgroup-element/" rel="bookmark" class="crp_title">The hgroup element</a></li><li><a href="http://html5doctor.com/the-hgroup-hokey-cokey/" rel="bookmark" class="crp_title">The hgroup hokey cokey</a></li><li><a href="http://html5doctor.com/your-questions-5/" rel="bookmark" class="crp_title">Your Questions Answered #5</a></li><li><a href="http://html5doctor.com/your-questions-answered-6/" rel="bookmark" class="crp_title">Your Questions Answered #6</a></li><li><a href="http://html5doctor.com/the-section-element/" rel="bookmark" class="crp_title">The section element</a></li></ul></div><p><a href="http://html5doctor.com/outlines/" rel="bookmark">Document Outlines</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 12, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/outlines/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Go offline with application cache</title>
		<link>http://html5doctor.com/go-offline-with-application-cache/</link>
		<comments>http://html5doctor.com/go-offline-with-application-cache/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 15:00:48 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[JavaScript APIs]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[offline]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2729</guid>
		<description><![CDATA[<p>HTML5 introduces new methods for enabling a web site or web application to function without a network connection. When you're working on a mobile connection and your signal drops, or you just have no connection to the internet for whatever reason, having some level of access is better than nothing. In this article, we'll look at how the application cache can store resources to be used by the browser when it's offline, granting your users partial access to your web site or application.</p>]]></description>
			<content:encoded><![CDATA[<p><abbr>HTML</abbr>5 introduces new methods for enabling a web site or web application to function without a network connection. When you&#8217;re working on a mobile connection and your signal drops, or you just have no connection to the internet for whatever reason, having some level of access is better than nothing. In this article, we&#8217;ll look at how the application cache can store resources to be used by the browser when it&#8217;s offline, granting your users partial access to your web site or application.</p>

<p>The <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html">application cache</a> is controlled by a plain text file called a manifest, which contains a list of resources to be stored for use when there is no network connectivity. The list can also define the conditions for caching, such as which pages should never be cached and even what to show the user when he follows a link to an uncached page.</p>

<p>If the user goes offline but has visited the site while online, the cached resources will be loaded so the user can still view the site in a limited form. By carefully considering the contents of your manifest file, you can offer a suitable web experience to a disconnected user.</p>

<section id="manifest">
  <h2>The manifest file</h2>
  <p>Let&#8217;s start with an example of a full manifest file. (Don&#8217;t worry, I&#8217;ll explain it all in detail!)</p>
  
  <figure>
    <pre><code>CACHE MANIFEST
      
# This is a comment

CACHE:
/css/screen.css
/css/offline.css
/js/screen.js
/img/logo.png

http://example.com/css/styles.css

FALLBACK:
/ /offline.html

NETWORK:
*
</code></pre>
    <figcaption>An example application cache manifest file</figcaption>
  </figure>
  
  <p>Each directive is placed on a new line, with comments prefixed by a hash (#). The first line, <code>CACHE MANIFEST</code>, tells the browser that this is a manifest file. The uppercased lines with trailing colons are section headings.</p>
  
  <p>There are three different sections in a manifest file:</p>
  
  <dl>
    <dt>CACHE</dt>
    <dd>A list of explicit <abbr>URL</abbr>s to request and store</dd>
    <dt>FALLBACK</dt>
    <dd>What to do when an offline user attempts to access an uncached file</dd>
    <dt>NETWORK</dt>
    <dd>Which resources are available only while online</dd>
  </dl>
  
  <p>Each section serves a specific purpose that you must understand in order to successfully and effectively cache your resources.</p>
  
  <section id="cache">
    <h3>CACHE</h3>
    <p>The <code>CACHE</code> section is considered the default — i.e., if no section heading has been defined, the browser will assume this is the <code>CACHE</code> section. Beneath this heading, you can list <abbr>URI</abbr>s to resources you want the browser to download and cache for offline use, including <abbr>URI</abbr>s hosted externally.</p>
  
    <figure>
      <pre><code>CACHE MANIFEST

/css/screen.css
/css/offline.css
/js/screen.js
/img/logo.png

http://example.com/css/widget.css</code></pre>

      <figcaption>Telling the browser to cache some stylesheets, an image, and a JavaScript file</figcaption>
    </figure>
  
    <p>In this example, I&#8217;ve omitted the <code>CACHE:</code> heading to take advantage of the default behaviour. I have provided the browser with four paths relative to the root of the domain plus one external resource. When the browser downloads the cache manifest file, it will read these five resources, fetch them over <abbr>HTTP</abbr>, and store them for later use.</p>
  
    <p>Every single resource that you want to cache explicitly should be listed here, right down to the last image. The browser is not aware of a resource unless you provide the full path to it. This means <strong>you can&#8217;t use wildcards</strong>. If you list <code>/images/*</code> as a resource, the browser will request that <abbr>URI</abbr> as if you typed it into your address bar.</p>
  
    <p>But don&#8217;t run off and shove <abbr>URI</abbr>s for every single page on your site into your manifest! When a user visits a page that points to the manifest file, that page will also be cached. This means that if you want to allow users access to pages they&#8217;ve already viewed, just make those pages point to the manifest file and the browser will cache them appropriately.</p>
  
    <p>Now let&#8217;s tell the browser what to do with uncached resources.</p>
  </section>
  
  <section id="fallback">
    <h3>FALLBACK</h3>
  
    <p>The <code>FALLBACK</code> section tells the browser what to serve when the user tries to access an uncached resource while offline. Because of this, it looks a bit different than <code>CACHE</code> and <code>NETWORK</code>. It contains two values per line, separated by a space. The first value is the request <abbr>URI</abbr> to match, and the second is the resource sent upon matching. It caches the resource on the right for offline use, so this should be an explicit path.</p>
    
    <p>Lost? Take a look at this example:</p>
  
    <figure>
      <pre><code>CACHE MANIFEST

FALLBACK:
/status.html /offline.html</code></pre>
      <figcaption>Declaring a <code>FALLBACK</code> section</figcaption>
    </figure>
  
    <p>On the line below <code>FALLBACK:</code>, we have the <abbr>URI</abbr> &#8220;/status.html&#8221; followed by a second <abbr>URI</abbr>, &#8220;/offline.html&#8221;. We&#8217;re telling the browser that when an offline user requests a <abbr>URI</abbr> matching &#8220;/status.html&#8221;, it should instead serve the cached file &#8220;offline.html&#8221;.</p>
    
    <p>However, the <code>FALLBACK</code> section can be far more powerful:</p>
  
    <figure>
      <pre><code>CACHE MANIFEST

FALLBACK:
/ /offline.html</code></pre>
      <figcaption>Matching all resources</figcaption>
    </figure>
  
    <p>In this example, I&#8217;ve dropped &#8220;status.html&#8221; and simply provided &#8220;/&#8221; as the request <abbr>URI</abbr> to match. Now when an offline user requests a resource that matches &#8220;/&#8221;, he will be served &#8220;offline.html&#8221; in its place. So if the user clicked on a link for &#8220;/status.html&#8221;, &#8220;/about.html&#8221;, or even &#8220;/my/nested/resource.html&#8221;, the browser would match the &#8220;/&#8221; at the start and serve up &#8220;offline.html&#8221;. Since I&#8217;ve used the root path, every uncached resource under this domain will point to &#8220;offline.html&#8221;.</p>
  
    <p class="disclaimer"><strong>Errata 23 June 2011:</strong> this article has been corrected as you <em>can&#8217;t</em> use a wildcard with the <code>FALLBACK</code> or <code>NETWORK</code> namespaces &#8211; though you can use the asterisk symbol under <code>NETWORK</code> as it&#8217;s a special flag to indicate all urls should be whitelisted.</p>

    <p>The <code>CACHE</code> section, both the <code>FALLBACK</code> and <code>NETWORK</code> namespaces support a prefix rule that aid their <abbr>URI</abbr> matching. In that any requests to the <code>/avatar</code> directory, whilst offline, if the asset is unavailable the browser can serve up an alternative.</p>
    
    <figure>
      <pre><code>CACHE MANIFEST

FALLBACK:
/images/avatars/ /offline_avatar.png</code></pre>
      <figcaption>A smarter fallback declaration</figcaption>
    </figure>
  
    <p>The first line tells the browser to serve &#8220;/offline_avatar.png&#8221; in place of user-uploaded avatars.</p>
  
    <p>Remember when I said that any document referencing the manifest will also be cached? Well, you can use this to your advantage! You can cache each page the user visits while online so that they will have access to that page while offline. Then anything they didn&#8217;t view will be caught by the <code>FALLBACK</code> section. This keeps you from explicitly stating you want all your pages cached, and, more importantly, avoids the huge performance penalty of serving all the resources you want cached every time someone first visits your site.</p>
  </section>
  
  <section id="network">
    <h3>NETWORK</h3>
    <p>Finally, we have the <code>NETWORK</code> section, used to tell the browser explicitly which resources are only available while online. By default, this uses the asterisk <code>*</code> symbol, meaning all resources that are not cached will require a connection. Alternatively we can whitelist specific url prefixes, like all the avatars if we wish.</p>
  
    <figure>
      <pre><code>CACHE MANIFEST

NETWORK:
*</code></pre>
      <figcaption>Adding a <code>NETWORK</code> section</figcaption>
    </figure>
  
    <p>You can explicitly define resources not to cache by providing a list of <abbr>URI</abbr>s — essentially a whitelist of online-only assets.</p>
  
    <figure>
      <pre><code>CACHE MANIFEST

NETWORK:
register.php
login.php</code></pre>
      <figcaption>Excluding certain pages from caching</figcaption>
    </figure>
  </section>

</section>

<section id="serving-manifest">
  <h2>Serving the manifest</h2>
  
  <p>You can reference a manifest file on a web page by adding the <code>manifest</code> attribute to your opening <code>&lt;html&gt;</code> tag. The browser will only cache pages that include this attribute (in addition to those specified in the manifest itself, though in that instance, the user would have to visit a page including the manifest in order for the browser to be aware of it).</p>
  
  <figure>
    <pre><code>&lt;!DOCTYPE html&gt;
&lt;html lang="en" manifest="/offline.appcache"&gt;
  // your html document
&lt;/html&gt;
</code></pre>
    <figcaption>Referencing the manifest file from an <abbr>HTML</abbr> page</figcaption>
  </figure>

  <p>The linked file should also be served with a <abbr>MIME</abbr>-type of <code>text/cache-manifest</code>. If you&#8217;re using <a href="http://httpd.apache.org/">Apache</a> as your web server, add this to your <code>.htaccess</code> file:</p>
  
  <figure>
    <pre><code>AddType text/cache-manifest .appcache
</code></pre>
  </figure>
  
  <p>And there you have it! Supporting browsers will retrieve the manifest file and cache each item on the list for offline use. Won&#8217;t your parents be proud?</p>
</section>

<section id="trigger-refresh">
  <h2>Triggering a cache refresh</h2>
  
  <p>Once a cache has been successfully downloaded, the browser will retain those assets until either the user clears the cache or you trigger an update. Triggering an update with your manifest file requires that the contents of that file change, not just the assets themselves.</p>
  
  <p><strong>Updating the assets on your server will not trigger a cache update. You must modify the manifest file.</strong></p>
  
  <p>If you&#8217;re adding or removing resources completely, you&#8217;ll have to edit your manifest file anyway. But what if you&#8217;re just amending an already cached stylesheet?</p>
  
  <p>This is where comments come in handy. Just throw in a simple version number comment that you change when you want to trigger an update:</p>
  
  <figure>
    <pre><code>CACHE MANIFEST
      
# Version 9

CACHE:
/css/screen.css</code></pre>
    <figcaption>A version comment in a manifest file</figcaption>
  </figure>

  <p>The next time you want to trigger a cache refresh, just increment the version number. When the user next visits the online version of a page including this manifest, it will re-download the manifest file, notice the change, download the listed assets, and purge the existing cache.</p>
  
  <p><strong>Browser bug:</strong> Firefox caches the manifest file itself and will not update it even if the manifest has changed on the server. With some server config wizardry, you can tell browsers that the cache of the manifest file is instantly invalidated and should be requested from the server every time it&#8217;s referenced. Add this to your <code>.htaccess</code> to put Firefox in its place:</p>
  
  <figure>
    <pre><code>&lt;IfModule mod_expires.c&gt;
  ExpiresActive On
  ExpiresByType text/cache-manifest "access plus 0 seconds"
&lt;/IfModule&gt;
</code></pre>
  </figure>
</section>

<section id="conclusion">
  <h2>Conclusion</h2>
  
  <p>The application cache is a powerful beast, and to tame it you need to be clear on what&#8217;s involved. Give thought to your <code>CACHE</code>, <code>FALLBACK</code>, and <code>NETWORK</code> sections to provide a suitable offline experience to your users.</p>
  
  <p>In a future article, we&#8217;ll show you how to use the <code>applicationCache</code> JavaScript object to manipulate the cache. Until then, this should be enough to get you started on the path to offline web content.</p>
  
  <p>You can see a live demo using the application cache over on Doctor Remy&#8217;s <a href="http://html5demos.com/offlineapp">HTML5 Demos</a>. Happy caching!</p>
</section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/your-questions-answered-9/" rel="bookmark" class="crp_title">Your Questions Answered 9</a></li><li><a href="http://html5doctor.com/your-questions-answered-10/" rel="bookmark" class="crp_title">Your Questions Answered #10</a></li><li><a href="http://html5doctor.com/the-nsfw-element/" rel="bookmark" class="crp_title">The nsfw element</a></li><li><a href="http://html5doctor.com/server-sent-events/" rel="bookmark" class="crp_title">Server-Sent Events</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></ul></div><p><a href="http://html5doctor.com/go-offline-with-application-cache/" rel="bookmark">Go offline with application cache</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on January 25, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/go-offline-with-application-cache/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>You can still use div</title>
		<link>http://html5doctor.com/you-can-still-use-div/</link>
		<comments>http://html5doctor.com/you-can-still-use-div/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 13:30:37 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[semantics]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1853</guid>
		<description><![CDATA[&#8220;Sorry, can you say that again?&#8221;, I hear you ask. Certainly: you can still use &#60;div&#62;! Despite HTML5 bringing us new elements like &#60;article&#62;, &#60;section&#62;, and &#60;aside&#62;, the &#60;div&#62; element still has its place. Let the HTML5 Doctor tell you why. Status: Unchanged In HTML 4, the &#60;div&#62; element was defined to be a generic [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Sorry, can you say that again?&#8221;, I hear you ask. Certainly: you can still use <code>&lt;div&gt;</code>! Despite <abbr title="HyperText Markup Language">HTML</abbr>5 bringing us new elements like <code>&lt;article&gt;</code>, <code>&lt;section&gt;</code>, and <code>&lt;aside&gt;</code>, the <code>&lt;div&gt;</code> element still has its place. Let the <abbr>HTML</abbr>5 Doctor tell you why.</p>
<p><span id="more-1853"></span></p>
<h2>Status: Unchanged</h2>
<p>In <abbr>HTML</abbr> 4, the <code>&lt;div&gt;</code> element was defined to be a generic element for structuring a page. Although you can allude to the nature of its content by assigning <code>id</code> and <code>class</code> attributes with meaningful names, a <code>&lt;div&gt;</code> has almost no semantic meaning. <a href="http://dev.w3.org/html5/spec/Overview.html#the-div-element">The <abbr>HTML</abbr>5 definition</a>is basically the same as in <abbr>HTML</abbr> 4:</p>
<blockquote>
<p>The div element has no special meaning at all. It represents its children. It can be used with the class, lang, and title attributes to mark up semantics common to a group of consecutive elements.</p>
<footer>
    <cite><a href="http://dev.w3.org/html5/spec/Overview.html#the-div-element">W3C Specification</a></cite><br />
  </footer>
</blockquote>
<p><code>&lt;div&gt;</code> is literally a container for flow content*, a collection of (hopefully) more semantically marked-up content that may need to be grouped together. It lies at the opposite end of the semantic spectrum from the new <abbr>HTML</abbr>5 structural elements.</p>
<p><small>* For those who haven&#8217;t encountered this term before, <a href="http://dev.w3.org/html5/spec/Overview.html#flow-content-0">flow content</a> elements are the same as <abbr>HTML</abbr> 4&#8242;s block-level content elements.</small></p>
<h2><code>&lt;div&gt;</code> vs semantic elements</h2>
<p>The new semantic elements (<code>&lt;article&gt;</code>, <code>&lt;section&gt;</code>, and friends) justifiably capture a lot of <code>&lt;div&gt;</code>&#8216;s territory, but <code>&lt;div&gt;</code> still has a place in the <abbr>HTML</abbr>5 world. You should use <code>&lt;div&gt;</code> when there is no other more semantically appropriate element that suits your purpose. Its most common use will likely be for stylistic purposes — i.e., wrapping some semantically marked-up content in a <abbr>CSS</abbr>-styled container.</p>
<p>Ask yourself questions about your content: Is it part of the site&#8217;s navigation? Is the content secondary to its surrounding content? If this content were printed on a page with nothing else, would it make sense? You will need to evaluate your content carefully, thinking about what it is and pairing it with an appropriate element. I recommend taking a look at <a href="http://html5doctor.com/happy-1st-birthday-us/">The Amazing <abbr>HTML</abbr>5 Doctor Easily Confused <abbr>HTML</abbr>5 Element Flowchart of Enlightenment</a> to help you choose the right element for your flow content.</p>
<h2>Example Uses</h2>
<p>Below are a few examples of how you can still use <code>&lt;div&gt;</code> appropriately in your <abbr>HTML</abbr>5 sites.</p>
<h3>Site Wrapper</h3>
<p>While you can <a href="http://camendesign.com/code/developpeurs_sans_frontieres">use the <code>&lt;body&gt; element</code></a> as a &#8220;natural&#8221; wrapper for site content, many people like to use <code>&lt;div&gt;</code> as top-level container for styling the entire site. This is an appropriate use of <code>&lt;div&gt;</code>, as a site wrapper has no meaning or purpose other than to aid styling.</p>
<pre><code>&lt;body&gt;
  &lt;div id="wrapper"&gt;
    &lt;header&gt;
      &lt;h1&gt;My Happy Blog&lt;/h1&gt;
      &lt;nav&gt;
        &lt;!-- ... --&gt;
      &lt;/nav&gt;
    &lt;/header&gt;

    &lt;!-- ... rest of site content ... --&gt;
  &lt;/div&gt;
&lt;/body&gt;</code></pre>
<h3>Intro paragraph</h3>
<p>If you want to style a particular block of content, like the intro to an article, <code>&lt;div&gt;</code> is a perfectly suitable element:</p>
<pre><code>&lt;article&gt;
  &lt;h1&gt;Big announcement&lt;/h1&gt;
  &lt;div class="intro"&gt;
    &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
    &lt;p&gt;Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.&lt;/p&gt;
  &lt;/div&gt;
  &lt;p&gt;Sed massa metus, molestie nec facilisis non, lobortis ac orci. Suspendisse porttitor laoreet mi, at laoreet dolor rhoncus non. Sed ut massa quis mi placerat iaculis non sit amet odio. Cras tempus urna vitae felis rutrum porta.&lt;/p&gt;
  &lt;p&gt;Maecenas auctor lacus eget mauris tincidunt consectetur. Donec molestie malesuada ligula, sed feugiat massa consequat sit amet. Pellentesque orci metus, ultricies sit amet adipiscing eget, gravida fringilla dui. Vestibulum accumsan dui diam, eget venenatis urna. Sed eu lobortis justo. Aliquam erat volutpat. Aliquam erat volutpat.&lt;/p&gt;
&lt;/article&gt;</code></pre>
<p>The first two paragraphs aren&#8217;t really that different from the rest of the article, but by wrapping them in a <code>&lt;div&gt;</code>, they can be styled to capture the reader&#8217;s attention and draw them into the article. Of course, if you only want to style the first paragraph, you could use a <abbr>CSS</abbr> selector like <code>h1 + p {}</code> or <code>article p:first-child {}</code>. But if you want to style an article&#8217;s first paragraph only <em>sometimes</em>, or you need the style to work in older versions of Internet Explorer, or (as in this case) you want style more than one paragraph, a wrapper <code>&lt;div&gt;</code> is the way to go.</p>
<h3>Other uses for <code>&lt;div&gt;</code></h3>
<p>As previously stated, use of <code>&lt;div&gt;</code> will decline in favour of the new semantic elements. If you&#8217;re using lots of <code>&lt;div&gt;</code>s and only a few of the semantic elements in your <abbr>HTML</abbr>5 sites, then you&#8217;re really not taking advantage of what <abbr>HTML</abbr>5 has to offer.</p>
<p>That said, you may need to rely on <code>&lt;div&gt;</code> as you transition into the world of <abbr>HTML</abbr>5. For example, if many of your site&#8217;s visitors use Internet Explorer with JavaScript disabled, then you won&#8217;t be able to style the new elements for these users. A piece of advice we gave back in our article on <a href="http://html5doctor.com/how-to-use-html5-in-your-client-work-right-now/">how to use <abbr>HTML</abbr>5 in your client work right now</a> was to use <code>&lt;div&gt;</code> with classes named after the new semantic elements, getting you to think about how you would use the new semantic elements without actually using them.</p>
<pre><code>&lt;div class="article"&gt;
  &lt;div class="header"&gt;
    &lt;h1&gt;My blog post&lt;/h1&gt;
    &lt;p&gt;An example using divs with classes instead of the new elements.&lt;/p&gt;
  &lt;/div&gt;
  &lt;!-- ... content ... --&gt;
&lt;/div&gt;

&lt;article&gt;
  &lt;header&gt;
    &lt;h1&gt;My blog post&lt;/h1&gt;
    &lt;p&gt;The same article but switched to the new elements.&lt;/p&gt;
  &lt;/header&gt;
  &lt;!-- ... content ... --&gt;
&lt;/article&gt;</code></pre>
<p>This makes it simple to switch to the new elements when it becomes practical (think &#8220;search and replace&#8221;).</p>
<h2>Recap</h2>
<p>You will certainly use <code>&lt;div&gt;</code> less often in <abbr>HTML</abbr>5 than you did in <abbr>HTML</abbr> 4, but it&#8217;s still a valuable element to have in your toolkit. Sure, it&#8217;ll be picked last for the team because everyone else is better, but it&#8217;ll be the best damn generic container element there is!*</p>
<p>Look at the more semantically valuable elements and consider whether your content would benefit from what they offer. Need help deciding? Take a look at some of these articles right here on <abbr>HTML</abbr>5 Doctor:</p>
<ul>
<li><a href="http://html5doctor.com/the-header-element/">header</a></li>
<li><a href="http://html5doctor.com/the-footer-element/">footer</a></li>
<li><a href="http://html5doctor.com/aside-revisited/">aside</a></li>
<li><a href="http://html5doctor.com/the-article-element/">article</a></li>
<li><a href="http://html5doctor.com/the-section-element/">section</a></li>
<li><a href="http://html5doctor.com/the-figure-figcaption-elements/">figure</a></li>
<li><a href="http://html5doctor.com/nav-element/">nav</a></li>
</ul>
<p>For more, check our <a href="http://html5doctor.com/article-archive/">article archive</a>. And if all else fails, use a <code>&lt;div&gt;</code>!</p>
<p><small>* As it should be, it&#8217;s the only one apart from <code>&lt;span&gt;</code>. That said, if your content is just text, perhaps the oft-overlooked <code>&lt;p&gt;</code> would be more appropriate.</small>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/understanding-aside/" rel="bookmark" class="crp_title">Understanding aside</a></li>
<li><a href="http://html5doctor.com/aside-revisited/" rel="bookmark" class="crp_title">Aside Revisited</a></li>
<li><a href="http://html5doctor.com/the-details-and-summary-elements/" rel="bookmark" class="crp_title">The details and summary elements</a></li>
<li><a href="http://html5doctor.com/the-header-element/" rel="bookmark" class="crp_title">The header element</a></li>
<li><a href="http://html5doctor.com/the-hgroup-element/" rel="bookmark" class="crp_title">The hgroup element</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/you-can-still-use-div/" rel="bookmark">You can still use div</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 13, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/you-can-still-use-div/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>The dl element</title>
		<link>http://html5doctor.com/the-dl-element/</link>
		<comments>http://html5doctor.com/the-dl-element/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 14:00:10 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[dl]]></category>
		<category><![CDATA[dt]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=725</guid>
		<description><![CDATA[The &#60;dl&#62; element existed in HTML 4, but it&#8217;s been repurposed in HTML5. Let the Doctor explain what&#8217;s changed and how it can be used. It’s all in the description In HTML 4, &#60;dl&#62; was considered a “definition list”, containing groups of terms and their definitions. The terms and definitions were a many-to-many relationship: one [...]]]></description>
			<content:encoded><![CDATA[<p>The <code>&lt;dl&gt;</code> element existed in <abbr title="Hypertext Mark-up Language">HTML</abbr> 4, but it&#8217;s been repurposed in <abbr>HTML</abbr>5. Let the Doctor explain what&#8217;s changed and how it can be used.</p>
<p><span id="more-725"></span></p>
<h2>It’s all in the description</h2>
<p>In <abbr>HTML</abbr> 4, <code>&lt;dl&gt;</code> was considered a “definition list”, containing groups of terms and their definitions. The terms and definitions were a many-to-many relationship: one or more terms to one or more definitions. The element was often misunderstood and therefore misused or not used at all in favour of more widely used and (perhaps) less semantic markup.</p>
<p>To address these issues, <code>&lt;dl&gt;</code>’s definition has been refined in <abbr>HTML</abbr>5 as a <a href="http://www.w3.org/TR/html-markup/dl.html#dl">description list</a>. From the spec:</p>
<blockquote><p>The dl element represents an association list consisting of zero or more name-value groups (a description list). Each group must consist of one or more names (dt elements) followed by one or more values (dd elements). Within a single dl element, there should not be more than one dt element for each name.</p>
</blockquote>
<p>It maintains the many-to-many relationship between names and values. These groupings use <a href="http://www.w3.org/TR/html-markup/dt.html#dt"><code>&lt;dt&gt;</code></a> to represent the term or name and <a href="http://www.w3.org/TR/html-markup/dd.html#dd"><code>&lt;dd&gt;</code></a> for the description. Also note the last line of the quote, stating that a name should not be used more than once within a single <code>&lt;dl&gt;</code>.</p>
<h2>Example Uses</h2>
<p>I&#8217;ve put together a couple of appropriate uses of <code>&lt;dl&gt;</code> to get your creative juices flowing.</p>
<h3>Glossary</h3>
<p><code>&lt;dl&gt;</code> can be used to mark-up a glossary of terms, although you must remember to use <code>&lt;dfn&gt;</code> to indicate that the word is defined here:</p>
<pre><code>&lt;article&gt;
  &lt;h1&gt;The article element&lt;/h1&gt;
  &lt;p&gt;An independent piece of content, one suitable for putting in an
    article element, is content that makes sense on it&rsquo;s own. This yardstick
    is up to your interpretation, but an easy smell test is would this make sense
    in an RSS feed? Of course weblog articles and static pages would make sense
    in a feed reader, and some sites have weblog comment feeds..&lt;/p&gt;
  ...
  &lt;aside&gt;
    &lt;h2&gt;Glossary&lt;/h2&gt;
    &lt;dl&gt;
      &lt;dt&gt;&lt;dfn&gt;RSS&lt;/dfn&gt;&lt;/dt&gt;
      &lt;dd&gt;An XML format for aggregating information from websites whose
        content is frequently updated.&lt;/dd&gt;
      &lt;dt&gt;&lt;dfn&gt;Weblog&lt;/dfn&gt;&lt;/dt&gt;
      &lt;dd&gt;Contraction of the term &quot;web log&quot;, a weblog is a
        website that is periodically updated, like a journal&lt;/dd&gt;
    &lt;/dl&gt;
  &lt;/aside&gt;
&lt;/aticle&gt;
</code></pre>
<p>The example content is from <a href="http://html5doctor.com/the-article-element/">our recent post on the article element</a>. In the example, I plucked out the terms &#8220;RSS&#8221; and &#8220;weblog&#8221; and defined them in a handy glossary. Since this information is supplementary to the article, the glossary has been placed in an <code>&lt;aside&gt;</code>.</p>
<h3>Metadata</h3>
<p><code>&lt;dl&gt;</code> is also appropriate for marking up content metadata, such as information about our article on <a href="http://html5doctor.com/how-to-use-html5-in-your-client-work-right-now/">how to use <abbr>HTML</abbr>5 in your client work right now</a>.</p>
<pre><code>&lt;dl&gt;
  &lt;dt&gt;Authors:&lt;/dt&gt;
  &lt;dd&gt;Remy Sharp&lt;/dd&gt;
  &lt;dd&gt;Rich Clark&lt;/dd&gt;
  &lt;dt&gt;Editor:&lt;/dt&gt;
  &lt;dd&gt;Brandan Lennox&lt;/dd&gt;
  &lt;dt&gt;Category:&lt;/dt&gt;
  &lt;dd&gt;Comment&lt;/dd&gt;
&lt;/dl&gt;
</code></pre>
<p>Since Remy and Richard contributed to that article, they are both listed as authors, showing the pairing of multiple values (<code>&lt;dd&gt;</code>) to one key (<code>&lt;dt&gt;</code>).</p>
<h3>Multiple keys (<code>&lt;dt&gt;</code>) to a single value</h3>
<p>As mentioned above, a <code>&lt;dl&gt;</code> may map many keys (<code>&lt;dt&gt;</code>) to many values (<code>&lt;dd&gt;</code>). This means that one term might have multiple descriptions, or there may be multiple terms that mean the same thing. Related <code>&lt;dt&gt;</code>s should follow each other immediately before their descriptive <code>&lt;dd&gt;</code>.</p>
<pre><code>&lt;dl&gt;
  &lt;dt lang="en-GB"&gt;&lt;dfn&gt;colour&lt;/dfn&gt;&lt;/dt&gt;
  &lt;dt lang="en-US"&gt;&lt;dfn&gt;color&lt;/dfn&gt;&lt;/dt&gt;
  &lt;dd&gt;The visual result of light in their emission, transmission and/or reflection. This perception is determined by the hue, brightness and saturation of the light at a specific point. &lt;/dd&gt;
&lt;/dl&gt;
</code></pre>
<p>Here I have indicated that there are two different spellings of &#8220;colour&#8221; and grouped these terms to match them with the same description.</p>
<p>It is not appropriate, however, to use the same key multiple times within a single <code>&lt;dl&gt;</code>. You can&#8217;t define &#8220;car&#8221; as one thing at the start of a <code>&lt;dl&gt;</code> and then define it again at the end of that same <code>&lt;dl&gt;</code>. If you have multiple descriptions for a single term, you should list both <code>&lt;dd&gt;</code>s directly under the same <code>&lt;dt&gt;</code>.</p>
<pre><code>&lt;dl&gt;
  &lt;dt&gt;&lt;dfn&gt;Chips&lt;/dfn&gt;&lt;/dt&gt;
  &lt;dd&gt;Strips of potato usually deep fried in fat. Commonly referred to as "french fries".&lt;/dd&gt;
  &lt;dd&gt;A small fragment that has been broken off from a larger body (e.g. stone).&lt;/dd&gt;
&lt;/dl&gt;
</code></pre>
<h2>What it should not be used for</h2>
<p>Dialogue was a suggested use for <code>&lt;dl&gt;</code> in <abbr>HTML</abbr> 4, which was widely debated and often considered inappropriate. This application of the element is no longer recommended in <abbr>HTML</abbr>5, and the new definition of the element does indeed back this up. When marking up a conversation, you&#8217;re not describing the speaker, but rather stating what they said. With the demise of <a href="http://html5doctor.com/a-little-more-conversation-with-dialog/"><code>&lt;dialog&gt;</code></a>, conversations have no specific markup element. Instead, the specification makes recommendations of <a href="http://dev.w3.org/html5/spec/Overview.html#conversations">how to mark up conversations</a>.</p>
<h2>Summary</h2>
<p>The changes to <code>&lt;dl&gt;</code> are fairly minor, but the new definition should clear up confusion and enable developers to use it more appropriately. You can use this element to represent key-value pairs semantically and couple it with other elements like <code>&lt;details&gt;</code> and <code>&lt;aside&gt;</code> to give context to this information.</p>
<p>Where do you see yourself using <code>&lt;dl&gt;</code> in <abbr>HTML</abbr>5? Perhaps details about a downloadable file? Or are you going to give your more technical blog articles a glossary? Let us know in the comments!</p>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/the-article-element/" rel="bookmark" class="crp_title">The article element</a></li>
<li><a href="http://html5doctor.com/a-little-more-conversation-with-dialog/" rel="bookmark" class="crp_title">A little more conversation with dialog</a></li>
<li><a href="http://html5doctor.com/html5-doctor-glossary/" rel="bookmark" class="crp_title">HTML5 Doctor Glossary</a></li>
<li><a href="http://html5doctor.com/aside-revisited/" rel="bookmark" class="crp_title">Aside Revisited</a></li>
<li><a href="http://html5doctor.com/your-questions-18/" rel="bookmark" class="crp_title">Your Questions 18</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/the-dl-element/" rel="bookmark">The dl element</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on June 3, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/the-dl-element/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>HTML5 Doctor Speaking and Training Appearances</title>
		<link>http://html5doctor.com/speaking/</link>
		<comments>http://html5doctor.com/speaking/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 13:30:40 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[talks]]></category>
		<category><![CDATA[training]]></category>
		<category><![CDATA[workshops]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1577</guid>
		<description><![CDATA[<p>Even after slaving away at the web's operating table, the <abbr>HTML</abbr>5 Doctors still find time to speak about <abbr>HTML</abbr>5 at industry events. We'd like to make sure you don't miss out on future chances to see the doctors in action.</p>]]></description>
			<content:encoded><![CDATA[<p>Even after slaving away at the web&#8217;s operating table, the <abbr>HTML</abbr>5 Doctors still find time to speak about <abbr>HTML</abbr>5 at industry events. We&#8217;d like to make sure you don&#8217;t miss out on future chances to see the doctors in action.</p>

<p>For your convenience, we&#8217;ve put together a list of events where we&#8217;ll be speaking and even the ones we&#8217;re simply attending. Read on for some of our upcoming <abbr>HTML</abbr>5 appearances.</p>

<p>We&#8217;ll continue to maintain this page with new listings, so check back often. Otherwise you might miss us!</p>

<section class="vcalendar">
  <h2>Upcoming Talks</h2>
  <p>Here are some of the <abbr>HTML</abbr>5 talks we will be giving at various events. Make sure you mark them down in your calendars!</p>
</section>

<section class="vcalendar">  
  <h2>In Attendance</h2>
  <p>Of course, we aren&#8217;t always talking. We still attend events to listen to talks ourselves. If you see us there, come and say hi.</p>
<article class="vevent"> 
  <h3 class="summary"> 
    <a href="http://atnd.org/events/5181" class="url">Designing for iPad; our experiences so far</a> 
  </h3> 
  <details open="open"> 
    <abbr class="dtstart" title="2010-07-21T19:00:00">21 Jul</abbr> &#8211; 
    <em class="attendee">Oli Studholme</em> &#8211; 
    <span class="location">Apple Ginza</span> 
  </details> 
</article>

<article class="vevent"> 
  <h3 class="summary"> 
    <a href="http://buildconf.com/" class="url">Build</a> 
  </h3> 
  <details open="open"> 
    <abbr class="dtstart" title="2010-11-10T09:00:00">10 Nov</abbr> &#8211; 
    <em class="attendee">Jack Osborne</em> &#8211; 
    <span class="location">Waterfront Studio, Belfast</span> 
  </details> 
</article>
</section>

<h2>Run an event? Get in touch!</h2>
<p>If you organise an event or workshop and would like us to speak (or you&#8217;d just like to see us there), then we&#8217;d love to <a href="http://html5doctor.com/contact/">hear from you</a>.</p><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/web-directions-atmedia-2010/" rel="bookmark" class="crp_title">HTML5 Doctor at Web Directions @media</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/microdata/" rel="bookmark" class="crp_title">Extending HTML5 — Microdata</a></li><li><a href="http://html5doctor.com/storing-data-the-simple-html5-way-and-a-few-tricks-you-might-not-have-known/" rel="bookmark" class="crp_title">Storing Data the Simple HTML5 Way (and a few tricks you might not have known)</a></li><li><a href="http://html5doctor.com/summary-figcaption-element/" rel="bookmark" class="crp_title">Hello, summary and figcaption elements</a></li></ul></div><p><a href="http://html5doctor.com/speaking/" rel="bookmark">HTML5 Doctor Speaking and Training Appearances</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on April 16, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/speaking/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Aside Revisited</title>
		<link>http://html5doctor.com/aside-revisited/</link>
		<comments>http://html5doctor.com/aside-revisited/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 14:23:57 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[aside]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1015</guid>
		<description><![CDATA[Since the <abbr>HTML</abbr>5 specification is not yet final, we can expect changes to improve on the good bits and cut out the bad bits. <code>aside</code> &#8212; a misunderstood good bit &#8212; has now been tweaked based on feedback from the web development community. In this article, we'll take a look at what's changed.]]></description>
			<content:encoded><![CDATA[<p>Since the <abbr>HTML</abbr>5 specification is not yet final, we can expect changes to improve on the good bits and cut out the bad bits. <code>aside</code> &#8212; a misunderstood good bit &#8212; has now been tweaked based on feedback from the web development community. In this article, we&#8217;ll take a look at what&#8217;s changed.</p>
<h2>Aside redefined</h2>
<p>When we previously discussed <code>aside</code> in &#8220;<a href="/understanding-aside/">Understanding Aside</a>&#8220;, its definition suggested that it should be used for content tangentially related to the content surrounding it, such as related reading links and glossaries. It did <em>not</em> appear to be an appropriate element for holding secondary content related to the site as a whole, typically known as a &#8220;sidebar&#8221;.</p>
<p>From the comments here and elsewhere, you can see this definition was not accepted by developers. The spec writers listened, and <code>aside</code> is now acceptable for secondary content when not nested within an <code>article</code> element.</p>
<h2>Examples of <code>aside</code> in two different contexts</h2>
<p>With the new definition of <code>aside</code>, it&#8217;s crucial to remain aware of its context. When used <em>within</em> an <code>article</code> element, the contents should be specifically related to that article (e.g., a glossary). When used <em>outside</em> of an <code>article</code> element, the contents should be related to the site (e.g., a blogroll, groups of additional <a href="/nav-element/">navigation</a>, and even advertising if that content is related to the page).</p>
<p>The two uses of <code>aside</code> can be best illustrated with an example:</p>
<pre><code>&lt;body&gt;
  &lt;header&gt;
    &lt;h1&gt;My Blog&lt;/h1&gt;
  &lt;/header&gt;
  &lt;article&gt;
    &lt;h1&gt;My Blog Post&lt;/h1&gt;
    &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
    eiusmod tempor incididunt ut labore et dolore magna aliqua.&lt;/p&gt;
    &lt;aside&gt;
      &lt;!-- Since this aside is contained within an article, a parser
      should understand that the content of this aside is directly related
      to the article itself. --&gt;
      &lt;h1&gt;Glossary&lt;/h1&gt;
      &lt;dl&gt;
        &lt;dt&gt;Lorem&lt;/dt&gt;
        &lt;dd&gt;ipsum dolor sit amet&lt;/dd&gt;
      &lt;/dl&gt;
    &lt;/aside&gt;
  &lt;/article&gt;
  &lt;aside&gt;
    &lt;!-- This aside is outside of the article. Its content is related
    to the page, but not as closely related to the above article --&gt;
    &lt;h2&gt;Blogroll&lt;/h2&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;My Friend&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;My Other Friend&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;My Best Friend&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/aside&gt;
&lt;/body&gt;
</code></pre>
<h2>Conclusion</h2>
<p>The <code>aside</code> element can now represent secondary content when used outside of an <code>article</code>. Keep in mind that <code>aside</code> &#8212; and, more generally, secondary content &#8212; does not <em>necessarily</em> mean &#8220;sidebar&#8221;. The style of the content should not dictate the use of the element. For content that is not the primary focus of an article (or page) but is still <em>related</em> to the article (or page), <code>aside</code> is what you need, regardless of its visual design.</p>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/understanding-aside/" rel="bookmark" class="crp_title">Understanding aside</a></li>
<li><a href="http://html5doctor.com/you-can-still-use-div/" rel="bookmark" class="crp_title">You can still use div</a></li>
<li><a href="http://html5doctor.com/designing-a-blog-with-html5/" rel="bookmark" class="crp_title">Designing a blog with html5</a></li>
<li><a href="http://html5doctor.com/the-hgroup-hokey-cokey/" rel="bookmark" class="crp_title">The hgroup hokey cokey</a></li>
<li><a href="http://html5doctor.com/the-dl-element/" rel="bookmark" class="crp_title">The dl element</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/aside-revisited/" rel="bookmark">Aside Revisited</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 28, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/aside-revisited/feed/</wfw:commentRss>
		<slash:comments>76</slash:comments>
		</item>
		<item>
		<title>Draw attention with mark</title>
		<link>http://html5doctor.com/draw-attention-with-mark/</link>
		<comments>http://html5doctor.com/draw-attention-with-mark/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 13:10:43 +0000</pubDate>
		<dc:creator>Mike Robinson</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[mark]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=771</guid>
		<description><![CDATA[Other than allowing Mark's everywhere to <em>rejoice</em> that they have an element that shares their name, HTML 5 introduces mark as a way to highlight text to indicate its relevance to the user. Read on as we tally up the uses of this new element.]]></description>
			<content:encoded><![CDATA[<p>Other than allowing Marks everywhere to <em>rejoice</em> that they have an element that shares their name, HTML 5 introduces <code>mark</code> as a way to highlight text to indicate its relevance to the user. Read on as we tally up the uses of this new element.<span id="more-771"></span></p>
<p>As always, the defining text passed down to us in the <a href="http://dev.w3.org/html5/spec/Overview.html#the-mark-element">specification</a>:</p>
<blockquote><p>The mark element represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context. When used in a quotation or other block of text referred to from the prose, it indicates a highlight that was not originally present but which has been added to bring the reader&#8217;s attention to a part of the text that might not have been considered important by the original author when the block was originally written, but which is now under previously unexpected scrutiny. When used in the main prose of a document, it indicates a part of the document that has been highlighted due to its likely relevance to the user&#8217;s current activity.</p>
</blockquote>
<p>Both uses are aimed at drawing attention to what is relevant to the user. <code>mark</code> can provide a very useful aid to the user with appropriate styling.</p>
<h2>Examples</h2>
<h3>Search Results</h3>
<p>A prime example of how to use <code>mark</code> today is to highlight the term a user has searched for. Many search engines already do this using other methods to mark the text, which shows the need for this new element.</p>
<pre><code>&lt;h1&gt;716,000,000 search results for the query &quot;&lt;mark&gt;HTML 5&lt;/mark&gt;&quot;&lt;/h1&gt;
&lt;section id=&quot;search-results&quot;&gt;
  &lt;article&gt;
    &lt;h2&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/HTML_5&quot;&gt;&lt;mark&gt;HTML 5&lt;/mark&gt; - Wikipedia, the free encyclopedia&lt;/a&gt;&lt;/h2&gt;
    &lt;p&gt;&lt;mark&gt;HTML 5&lt;/mark&gt; is the next major revision of &lt;mark&gt;HTML&lt;/mark&gt; (&quot;hypertext markup language&quot;), the core markup language of the World Wide Web. The WHATWG started work on the ... &lt;a href=&quot;http://en.wikipedia.org/wiki/HTML_5&quot;&gt;Read more&lt;/a&gt;&lt;/p&gt;
  &lt;/article&gt;
  &lt;article&gt;
    &lt;h2&gt;&lt;a href=&quot;http://dev.w3.org/html5/spec/Overview.html&quot;&gt;&lt;mark&gt;HTML 5&lt;/mark&gt;&lt;/a&gt;&lt;/h2&gt;
    &lt;p&gt;A vocabulary and associated APIs for &lt;mark&gt;HTML&lt;/mark&gt; and XHTML. Editor's Draft 16 August 2009. Latest Published Version: http://www.w3.org/TR/&lt;mark&gt;html5&lt;/mark&gt;/; Latest Editor's ... &lt;a href=&quot;http://dev.w3.org/html5/spec/Overview.html&quot;&gt;Read more&lt;/a&gt;&lt;/p&gt;
  &lt;/article&gt;
  &lt;article&gt;
    &lt;h2&gt;&lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/&quot;&gt;&lt;mark&gt;HTML 5&lt;/mark&gt;&lt;/a&gt;&lt;/h2&gt;
    &lt;p&gt;Multiple-page version: http://whatwg.org/&lt;mark&gt;html5&lt;/mark&gt;; One-page version: http://www.whatwg.org/specs/web-apps/current-work/; PDF print versions: ... &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/&quot;&gt;Read more&lt;/a&gt;&lt;/p&gt;
  &lt;/article&gt;
  &lt;article&gt;
    &lt;h2&gt;&lt;a href=&quot;http://html5gallery.com/&quot;&gt;&lt;mark&gt;HTML5&lt;/mark&gt; Gallery | A showcase of sites using &lt;mark&gt;HTML 5&lt;/mark&gt; markup&lt;/a&gt;&lt;/h2&gt;
    &lt;p&gt;A showcase of sites using &lt;mark&gt;html5&lt;/mark&gt; markup, with twin primary aims to help web designers and developers of how to implement &lt;mark&gt;html5&lt;/mark&gt; into their sites now, ... &lt;a href=&quot;http://html5gallery.com/&quot;&gt;Read more&lt;/a&gt;&lt;/p&gt;
  &lt;/article&gt;
&lt;/section&gt;
&lt;nav&gt;
  &lt;ol&gt;
    &lt;li&gt;1&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;...&lt;/li&gt;
  &lt;/ol&gt;
&lt;/nav&gt;
</code></pre>
<p><a href="http://jsbin.com/uleza">View a live example</a></p>
<p>Any instance of &#8220;HTML 5&#8243;, and even simply &#8220;HTML&#8221;, has been marked as relevant to the user&#8217;s search. This can help the user see how relevant their search results are, so they can pick the best results for what they need. When implementing this in a language like PHP, you can use functions like <a href="http://php.net/str_replace"><code>str_replace()</code></a> or some clever <a href="http://en.wikipedia.org/wiki/Regular_expression">regular expressions</a> to find the search term within your output and wrap <code>mark</code> around each instance.</p>
<h3>Quotes</h3>
<p>In all the brilliant things that have been said, there is always a chance that someone will come back to scrutinize parts in the future. These pieces of text or speech may not have had any importance when they were original formed, and hence not been given such emphasis, but now have attracted particular interest by a another party. <code>mark</code> can be used in quotations to highlight such text.</p>
<pre><code>&lt;p&gt;Mike once said:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Google won't last, &lt;mark&gt;they will fail&lt;/mark&gt; at search and advertising as nothing will topple Yahoo.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Of course, we now know he was wrong. Google has not failed, they excelled in search and online advertising, making them a very profitable company.&lt;/p&gt;
</code></pre>
<p>Here I have quoted myself, highlighting where I was wrong in my original statement and then immediately correcting this error in the following paragraph.</p>
<h2>Differences from strong and em</h2>
<p>Previously, you may have used <code>em</code> and <code>strong</code> for adding emphasis or importance, respectively, to portions of text. <code>mark</code> differs from these two as it is used purely for highlighting the relevance of a piece of text to the user and/or page&#8217;s content. In the past you may have used <code>em</code> and <code>strong</code> for this purpose, which was arguably valid at the time due to the lack of a better element, but the introduction of <code>mark</code> simply means their use will be more strict.</p>
<p>Use <code>strong</code> when you need to indicate the importance of a piece of text, such as an error or warning message, and <code>em</code> should be for adding emphasis to text, stressing words to adapt the meaning of a sentence.</p>
<h2>Final Thoughts</h2>
<p>The addition of <code>mark</code> to HTML is welcome, preventing stretching the definitions of <code>strong</code> and <code>em</code> too thin. There are many practical uses of <code>mark</code> in the world today, particularly for search and educational articles like tutorials. Put your highlighter pens down and start using <code>mark</code> to highlight relevant text (it&#8217;s better for your screen!).</p>
<p><small><strong>Disclaimer</strong>: I have nothing against Google, this was merely a fictitious example vaguely related to the use of <code>mark</code> in search. Long live Google?</small>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/html5-simplequiz-5-urls-of-commenters/" rel="bookmark" class="crp_title">HTML5 Simplequiz 5: URLs of commenters</a></li>
<li><a href="http://html5doctor.com/block-level-links-in-html-5/" rel="bookmark" class="crp_title">&#8220;Block-level&#8221; links in HTML5</a></li>
<li><a href="http://html5doctor.com/html5-simplequiz-4-figures-captions-and-alt-text/" rel="bookmark" class="crp_title">HTML5 Simplequiz #4: figures, captions and alt text</a></li>
<li><a href="http://html5doctor.com/aside-revisited/" rel="bookmark" class="crp_title">Aside Revisited</a></li>
<li><a href="http://html5doctor.com/html-5-boilerplates/" rel="bookmark" class="crp_title">HTML5 Boilerplates</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/draw-attention-with-mark/" rel="bookmark">Draw attention with mark</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on August 18, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/draw-attention-with-mark/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

