<?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; Richard Clark</title>
	<atom:link href="http://html5doctor.com/author/richc/feed/" rel="self" type="application/rss+xml" />
	<link>http://html5doctor.com</link>
	<description>helping you implement HTML5 today</description>
	<lastBuildDate>Wed, 01 Feb 2012 09:28:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>The output element</title>
		<link>http://html5doctor.com/the-output-element/</link>
		<comments>http://html5doctor.com/the-output-element/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 14:30:20 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[output]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3976</guid>
		<description><![CDATA[<p>Across the web, you’ll see a range of sites that feature calculators for working out things like loan repayments, mortgage rates, tax, insurance, and more. Until now, we’ve had no way of semantically marking up the result of those calculations. Enter: the <code>&#60;output&#62;</code> element! In this article, we’ll show you <code>&#60;output&#62;</code> and some related JavaScript tricks. Let’s get cracking.</p> ]]></description>
			<content:encoded><![CDATA[<p>Across the web, you’ll see a range of sites that feature calculators for working out things like loan repayments, mortgage rates, tax, insurance, and more. Until now, we’ve had no way of semantically marking up the result of those calculations. Enter: the <code>&lt;output&gt;</code> element! In this article, we’ll show you <code>&lt;output&gt;</code> and some related JavaScript tricks. Let’s get cracking.</p> 

<section id="definition">
  <h2>The Definition <a href="#definition" class="permalink">#</a></h2>
  
  <p>The <code>&lt;output&gt;</code> element, new in HTML5, is used in forms. The WHATWG HTML specification describes <code>&lt;output&gt;</code> very simply:</p>
  
  <blockquote>
    <p>The output element represents the result of a calculation.</p>
<footer>&mdash; <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-output-element">WHATWG HTML specification</a></cite></footer>
</blockquote>

  <p>Along with the standard <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#global-attributes">global attributes</a>, <code>&lt;output&gt;</code> also accepts the following:</p>
  
  <dl> 
    <dt><code>for</code></dt>
    <dd>A space-separated list containing the IDs of the elements whose values went into the calculation.</dd>
    <dt><code>form</code></dt>
    <dd>Associates the <code>&lt;output&gt;</code> element with its <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-owner">form owner</a>. The value must be the ID of a form in the same document. This allows you to place an <code>&lt;output&gt;</code> element outside of the <code>&lt;form&gt;</code> with which it is associated.</dd>
    <dt><code>name</code></dt>
    <dd>The name of the element.</dd>
  </dl>
</section>

<section id="implementation">
  <h2>Implementing <code>&lt;output&gt;</code> <a href="#implementation" class="permalink">#</a></h2>
  
  <p>We’ll start by creating a simple example that adds two whole numbers together (Figure 1). We’ll use the new-in-HTML5 <code>number</code> input type and the <code>parseInt</code> JavaScript function to convert the input strings to integers:</p>
  
  <figure>
    <pre><code>&lt;form onsubmit="return false" oninput="o.value = parseInt(a.value) + parseInt(b.value)"&gt;
  &lt;input name="a" type="number" step="any"&gt; +
  &lt;input name="b" type="number" step="any"&gt; =
  <mark>&lt;output name="o"&gt;&lt;/output&gt;</mark>
&lt;/form&gt;</code></pre>
  
    <img src="http://html5doctor.com/wp-content/uploads/2011/10/output-construction.png" alt="Construction of a calculation using the output element" />
  
    <figcaption>Figure 1: A simple calculator, rendered in Chrome</figcaption>
  </figure>
  
  <aside class="sidenote">
    <p><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-step-attribute">The <code>step</code> attribute</a> is new to HTML5. It defines the increment by which a <code>number</code> input increases and decreases.</p>
  </aside>    
  
  <div class="callout highlight-block">
    <p>Notice that we’re using the now-standard <code>oninput</code> event, which has replaced the <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=11129">deprecated <code>onforminput</code> event</a>. Daniel Friesen has written a detailed article on <a href="http://blog.danielfriesen.name/2010/02/16/html5-browser-maze-oninput-support/">the background and current support of <code>oninput</code></a>. <code>oninput</code> isn’t supported in IE8 and below, and its IE9 support is a little flaky, but you can work around these problems using <a href="http://www.useragentman.com/blog/2011/05/12/fixing-oninput-in-ie9-using-html5widgets/">the html5Widgets polyfill</a>.</p>
  </div>
  
  <p><a href="http://html5doctor.com/demos/output/1.html">See a live example of the code in Figure 1.</a></p>
  
  <p>As you’d expect, if you only enter a single value, the function returns <abbr title="Not a Number">NaN</abbr>. It’s effectively trying to add a number and an undefined value, and 1 + undefined = undefined.</p>
  
  <section id="for-attribute">
    <h3>Using the <code>for</code> Attribute <a href="#for-attribute" class="permalink">#</a></h3>
    
    <p>Let’s build on the previous example and add the <code>for</code> attribute to the <code>&lt;output&gt;</code> (Figure 2). We need to add IDs to each of the associated <code>&lt;input&gt;</code>s, just as we would with the <code>for</code> attribute on a <code>&lt;label&gt;</code>:</p>
    
    <figure>
      <pre><code>&lt;form onsubmit="return false" oninput="o.value = parseInt(a.value) + parseInt(b.value)"&gt;
  &lt;input name="a" id="a" type="number" step="any"&gt; +
  &lt;input name="b" id="b" type="number" step="any"&gt; =
  &lt;output name="o" <mark>for="a b"</mark>&gt;&lt;/output&gt;
&lt;/form&gt;</code></pre>

      <figcaption>Figure 2: Using the <code>for</code> attribute on the <code>&lt;output&gt;</code> element</figcaption>
    </figure>

    <p><a href="http://html5doctor.com/demos/output/2.html">See a live example of the code in Figure 2.</a></p>
  </section>
  
  <section id="valueAsNumber">
    <h3>The <code>valueAsNumber</code> Property <a href="#valueAsNumber" class="permalink">#</a></h3>
    
    <p>HTML5 has also introduced the <code>valueAsNumber</code> property of JavaScript input objects (specifically those of type number, date, and range). This returns the value as a number rather than as a string, meaning we no longer need to use <code>parseInt</code> or <code>parseFloat</code>, and the <code>+</code> operator adds rather than concatenates:</p>
    
    <figure>
      <pre><code>&lt;form onsubmit="return false" <mark>oninput="o.value = a.valueAsNumber + b.valueAsNumber"</mark>&gt;
  &lt;input name="a" id="a" type="number" step="any"&gt; +
  &lt;input name="b" id="b" type="number" step="any"&gt; =
  &lt;output name="o" for="a b"&gt;&lt;/output&gt;
&lt;/form&gt;</code></pre>

      <figcaption>Figure 3: Using the <code>valueAsNumber</code> property for retrieving a numeric value from an input</figcaption>
    </figure>

    <p><a href="http://html5doctor.com/demos/output/3.html">See a live example of the code in Figure 3.</a></p>
  </section>
</section>

<section id="invoicing-calculator">
  <h2>Invoicing Calculator: An In-depth Example with Fallbacks <a href="#invoicing-calculator" class="permalink">#</a></h2>
  
  <p>For a more realistic example, let’s create an invoicing calculator that multiplies the number of hours by the hourly rate and adds tax to give an overall total (Figure 4):</p>
  
  <figure>
    <pre><code>&lt;form onsubmit="return false" oninput="amount.value = (hours.valueAsNumber * rate.valueAsNumber) + ((hours.valueAsNumber * rate.valueAsNumber) * vat.valueAsNumber)"&gt;
  &lt;legend&gt;Invoice&lt;/legend&gt;

  &lt;p&gt;&lt;label for="hours"&gt;Number of hours&lt;/label&gt;
  &lt;input type="number" min="0" id="hours" name="hours"&gt;&lt;/p&gt;

  &lt;p&gt;&lt;label for="rate"&gt;Rate&lt;/label&gt;
  &lt;span&gt;&pound;&lt;/span&gt;&lt;input type="number" min="0" id="rate" name="rate"&gt;&lt;/p&gt;

  &lt;p&gt;&lt;label for="vat"&gt;VAT&lt;/label&gt;
  &lt;input type="number" min="0" id="vat" value="0.20" name="vat"&gt;&lt;/p&gt;

  &lt;p&gt;Total: &lt;strong&gt;&pound;&lt;output name="amount" for="hours rate vat"&gt;0&lt;/output&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/form&gt;</code></pre>

    <img src="http://html5doctor.com/wp-content/uploads/2011/10/invoice-calc.png" alt="Invoice tax calculator using the output element" />

    <figcaption>Figure 4: An invoicing calculator that renders its result in an <code>output</code> element</figcaption>
  </figure>

  <p><a href="http://html5doctor.com/demos/output/4.html">See a live example of the code in Figure 4.</a></p>
  
  <p>Nothing too complicated going on there. In fact, the scripting is so simple that even I can do it <img src='http://html5doctor.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
</section>

<section id="input-range">
  <h2>A Mildly Controversial Example Using <code>&lt;input type="range"&gt;</code> <a href="#input-range" class="permalink">#</a></h2>
  
  <p>HTML5 also introduces the <code>range</code> input type, which renders as a slider control in supporting browsers. With this input type, a user can enter an approximate value within a given range without having to be completely precise or directly type a numeric value. For cross browser compatibility, see <a href="http://remysharp.com/2011/07/18/input-range-polyfill/">Remy’s input range polyfill</a>.</p>
  
  <p>While researching this article, I found a number of examples using the <code>&lt;output&gt;</code> element in conjunction with <code>&lt;input type="range"&gt;</code> as shown in Figure 5:</p>
  
  <figure>
    <pre><code>&lt;form onsubmit="return false" oninput="level.value = flevel.valueAsNumber"&gt;
  &lt;label for="flying"&gt;Flying Skill Level&lt;/label&gt;
  &lt;input name="flevel" id="flying" type="range" min="0" max="100" value="0"&gt; 
  &lt;output for="flying" name="level"&gt;0&lt;/output&gt;/100
&lt;/form&gt;</code></pre>

    <img src="http://html5doctor.com/wp-content/uploads/2011/10/output-range.png" alt="Output example using type=range" />

    <figcaption>Figure 5: Using <code>&lt;input type="range"&gt;</code> with the <code>&lt;output&gt;</code> element</figcaption>
  </figure>
  
  <p><a href="http://html5doctor.com/demos/output/5.html">See a live example of the code in Figure 5.</a></p>
  
  <p>Using <code>&lt;output&gt;</code> to show the current value to the user seems like a perfectly reasonable use case to me, but it isn’t <q cite="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-output-element">the result of a calculation</q> as the spec describes. I haven’t spoken directly to Hixie about this, but a couple of people on the IRC channel seemed to agree with, so I filed a <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=14379">bug report</a> to request the definition be amended. I’ll update this article if something changes.</p>
</section>  

<section id="support">
  <h2>Browser Support and Polyfills <a href="#support" class="permalink">#</a></h2>
  
  <p>The good news is that all modern browsers support the <code>&lt;output&gt;</code> element to some extent. The bad news is that there are still a few gotchas.</p>
  
  <table class="wide">
    <caption>Browser support for the <code>&lt;output&gt;</code> element</caption>
    <thead>
      <tr>
        <th scope="col">Browser</th>
        <th scope="col">Support</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">Chrome</th>
        <td>13+</td>
      </tr>
      <tr>
        <th scope="row">Safari</th>
        <td>5.1+</td>
      </tr>
      <tr>
        <th scope="row">Firefox*</th>
        <td>6+</td>
      </tr>
      <tr>
        <th scope="row">Opera</th>
        <td>9.20+</td>
      </tr>
      <tr>
        <th scope="row">Internet Explorer</th>
        <td>10+</td>
      </tr>
    </tbody>
  </table>
  
  <p><small>* Firefox does support the <code>&lt;output&gt;</code> element and the <code>oninput</code> event, but <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=636737">it doesn’t support the <code>valueAsNumber</code> property</a>.</small></p>
  
  <p>All the examples we’ve seen so far should work perfectly in Opera 11.5+, Safari 5.1+, and Chrome 13+. IE, as you might expect, is lagging somewhat, but support for <code>&lt;output&gt;</code> is in IE10 Platform Preview 2, and support for <code>oninput</code> is already in IE9.</p>
  
  <p>In order to work around this in our simple examples, we’ll need to revert to the tried-and-trusted <code>getElementByID</code> and <code>parseFloat</code> (Figure 6):</p>
  
  <figure>
    <pre><code>&lt;form onsubmit="return false" <mark>oninput="document.getElementById('o').innerHTML = parseFloat(document.getElementById('a').value) + parseFloat(document.getElementById('b').value)"</mark>&gt;
  &lt;input name="a" id="a" type="number" step="any"&gt; +
  &lt;input name="b" id="b" type="number" step="any"&gt; =
  &lt;output name="o" id="o" for="a b"&gt;&lt;/output&gt;
&lt;/form&gt;</code></pre>

    <figcaption>Figure 6: Using <code>getElementById</code> to support older browsers</figcaption>
  </figure>

  <p><a href="http://html5doctor.com/demos/output/6.html">See a live example of the code in Figure 6.</a></p>

  <p>While this isn’t ideal, it’s workable until those less-capable browsers die a slow and painful death. Alternatively, you can use polyfills to plug the gaps.</p>
  
  <p>To check support in your current browser, <a href="http://miketaylr.com/code/html5-output-element-support.html">open up Mike Taylor’s support test page</a>.
  
  <section id="polyfills">
    <h3>Polyfills <a href="#polyfills" class="permalink">#</a></h3>
    
    <p>To support less-capable browsers, there are polyfills such as <a href="https://github.com/zoltan-dulac/html5Widgets">HTML5 Widgets</a> created by <cite><a href="http://www.useragentman.com">Zoltan &#8220;Du Lac&#8221; Hawryluk</a></cite>. Zoltan talks you through the process in <a href="http://www.useragentman.com/blog/2010/07/27/cross-browser-html5-forms-using-modernizr-webforms2-and-html5widgets/">this detailed article on creating cross browser forms using html5Widgets</a>.</p>
  </section>
</section>

<section id="summary">
  <h2>Summary <a href="#summary" class="permalink">#</a></h2>
  
  <p>You probably won&#8217;t find yourself using the <code>&lt;output&gt;</code> element all the time, but it’s useful in a whole host of situations. Calculating values on financial sites spring to mind, or outputting the current mouse position, or perhaps the goal difference in a table of sports teams. What other use cases can you think of for <code>&lt;output&gt;</code>? Let us know in the comments!</p>
</section>

<section id="links">
  <h2>Related reading <a href="#links" class="permalink">#</a></h2>
  
  <ul>
    <li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-output-element">WHATWG HTML Specification for <code>&lt;output&gt;</code></a></li>
    <li><a href="http://www.w3.org/wiki/HTML/Elements/output">W3C Elements Wiki Page for <code>&lt;output&gt;</code></a></li>
    <li><a href="http://wufoo.com/html5/elements/3-output.html">Wufoo HTML5 Forms Tests for <code>&lt;output&gt;</code></a></li>
    <li><a href="https://developer.mozilla.org/en/HTML/Element/output">Mozilla Developer Network docs on <code>&lt;output&gt;</code></a></li>
    <li><a href="http://www.useragentman.com/blog/2011/05/10/is-onforminput-deprecated-in-html5-forms-and-why-should-i-care-anyways/">Is <code>onforminput</code> Deprecated in HTML5 Forms? (And Why Should I Care Anyways?) by <cite>Zoltan Hawryluk</cite></a></li>
    <li><a href="http://blog.danielfriesen.name/2010/02/16/html5-browser-maze-oninput-support/">A HTML5 Browser Maze: <code>oninput</code> Support by <cite>Daniel Friessen</cite></a></li>
    <li><a href="http://www.useragentman.com/blog/2011/05/12/fixing-oninput-in-ie9-using-html5widgets/">Fixing <code>oninput</code> in IE Using html5Widgets by <cite>Zoltan Hawryluk</cite></a></li>
  </ul>
</section><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><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-contenteditable-attribute/" rel="bookmark" class="crp_title">The contenteditable attribute</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/video-subtitling-and-webvtt/" rel="bookmark" class="crp_title">Video Subtitling and WebVTT</a></li><li><a href="http://html5doctor.com/your-questions-answered-11/" rel="bookmark" class="crp_title">Your Questions Answered #11</a></li></ul></div><p><a href="http://html5doctor.com/the-output-element/" rel="bookmark">The output element</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on December 20, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/the-output-element/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Review: HTML5 Now (DVD)</title>
		<link>http://html5doctor.com/review-html5-now-dvd/</link>
		<comments>http://html5doctor.com/review-html5-now-dvd/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 13:30:30 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[dvd]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5now]]></category>
		<category><![CDATA[tantek]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3624</guid>
		<description><![CDATA[<p>We all learn in different ways. Some of us are readers or writers, some are kinesthetic learners, some prefer video or audio. If you fall into either of the latter two categories, Tantek Çelik’s DVD HTML5 Now might just be for you.</p>]]></description>
			<content:encoded><![CDATA[<p>We all learn in different ways. Some of us are readers or writers, some are kinesthetic learners, some prefer video or audio. If you fall into either of the latter two categories, <a href="http://twitter.com/t">Tantek Çelik’s</a> DVD <cite>HTML5 Now</cite> (Figure 1) might just be for you.</p>

<figure>
  <img src="http://html5doctor.com/wp-content/uploads/2011/09/html5-now.jpg" alt="HTML5 DVD">
  <figcaption>Figure 1: <cite>HTML5 Now</cite> DVD by Tantek Çelik</figcaption>
</figure>

<section>
  <h2>Overview</h2>
  <p>Personally, I’ve never been keen on video-based learning like this. As such, I wasn’t sure what I’d make of <cite>HTML5 Now</cite>. It turns out I was pleasantly surprised by the format, the content, and the presentation.</p>
  
  <p>Tantek has an natural, engaging presentation style, and his knowledge of the subject area ranks up there with the best of them. He begins with an interesting historical look at HTML and in turn how HTML5 came to be. This section is full of things you might not know about HTML, let alone HTML5.</p>
  
  <p>A few other thoughts:</p>
  
  <ul>
    <li>Tantek constantly urges you to get involved and share your experiences.</li>
    <li>The early parts of the DVD contain in-depth background information on elements and attributes.</li>
    <li>Tantek presents a clear, concise introduction to <code>&lt;ruby&gt;</code> and friends, even explaining how it’s worked in IE for 10+ years!</li>
    <li>He introduces his bulletproof HTML5 syntax (using <code>&lt;div&gt;</code>s with class names inside new elements).</li>
    <li>The accompanying booklet effectively takes notes for you so you don’t have to. Just sit back and enjoy!</li>
    <li>The DVD also contains the slides shown throughout the presentation and a PDF of the booklet.</li>
    <li>A few tongue-tied moments help keep it real, not staged or forced. It shows Tantek really cares about the subject.</li>
    <li>You’ll get some good tips on when to use the new elements. Additionally, some elements are more stable since the DVD was released.</li>
    <li>Each section is concluded by a brief summary recapping what you’ve learnt.</li>
  </ul>
</section>

<section>
  <h2>Words of warning</h2>
  <p>As is the case with any book or DVD based on the constantly evolving HTML5 specification, parts of the DVD are now out of date. (It was originally released in July 2010.) Look out for these gotchas:</p>
  
  <ul>
    <li>Certain sections don’t mention browser support.</li>
    <li><code>&lt;u&gt;</code> is now a part of the HTML5 specification.</li>
    <li>The WebM video codec didn’t exist at the time of production.</li>
    <li>There is no mention of form attributes and support for the new input types.</li>
    <li><code>&lt;canvas&gt;</code> is incorrectly described as a vector format (it’s bitmap).</li>
    <li>It’s a shame that Tantek only scratches the surface of <code>&lt;video&gt;</code>, <code>&lt;audio&gt;</code>, <code>&lt;canvas&gt;</code>, and SVG. They each deserve their own DVD!</li>
  </ul>
</section>

<section>
  <h2>Summary</h2>
  <p>I’m still not convinced that DVD is the best format for this type of content. As with print, it goes out of date very quickly. Alternatively, you could simply publish the video(s) on a website and make them available on a subscription basis. That way, outdated information could be updated more regularly. That’s a discussion for another day, though, and I’m sure Tantek would be keen to see it happen.</p>
  
  <p>In my opinion, the DVD is better suited to someone who has some prior knowledge of HTML and HTML5. It’s certainly not for beginners, but it does come recommended. You’ll definitely learn something. I’ll leave you with a video of Tantek (Figure 2) discussing the state of HTML5 at the Voices that Matter Conference just before the DVD was released:</p>

  <figure>
    <iframe width="500" height="375" src="http://www.youtube.com/embed/gUl9GdNk92o" frameborder="0" allowfullscreen></iframe>
    <figcaption>Figure 2: Tantek Çelik at the Voices That Matter: Web Design Conference 2010.</figcaption>
  </figure>
</section><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/review-html5-designing-rich-internet-applications/" rel="bookmark" class="crp_title">Review: HTML5 Designing Rich Internet Applications</a></li><li><a href="http://html5doctor.com/video-the-track-element-and-webm-codec/" rel="bookmark" class="crp_title">Video: the track element and webM codec</a></li><li><a href="http://html5doctor.com/video-subtitling-and-webvtt/" rel="bookmark" class="crp_title">Video Subtitling and WebVTT</a></li><li><a href="http://html5doctor.com/the-video-element/" rel="bookmark" class="crp_title">The video element</a></li><li><a href="http://html5doctor.com/u-element/" rel="bookmark" class="crp_title">The return of the u element</a></li></ul></div><p><a href="http://html5doctor.com/review-html5-now-dvd/" rel="bookmark">Review: HTML5 Now (DVD)</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 4, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/review-html5-now-dvd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Your Questions 18</title>
		<link>http://html5doctor.com/your-questions-18/</link>
		<comments>http://html5doctor.com/your-questions-18/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 13:30:00 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[dl]]></category>
		<category><![CDATA[hgroup]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=3132</guid>
		<description><![CDATA[<p>The clinic is getting busy with more HTML5 ailments. This week, we'll discuss name-value pairs, e-commerce with HTML5, lightboxes and modal windows, why we need new elements, and optional subtitles.</p>]]></description>
			<content:encoded><![CDATA[<p>The clinic is getting busy with more <abbr>HTML</abbr>5 ailments. This week, we&#8217;ll discuss name-value pairs, e-commerce with <abbr>HTML</abbr>5, lightboxes and modal windows, why we need new elements, and optional subtitles.</p>
<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Doctor treating a patient illustration" class="size-full wp-image-424" /></p>

<section>
  <h2>Name-value pairs in <abbr>HTML</abbr></h2>
  <p>Eric asked:</p>
  <blockquote>
    <p>I work on a lot of HR applications where we need to present data on employees. I&#8217;ve never been entirely clear on the best way to mark this up. For example:</p>

    <p>Name: John Smith<br />
    Organization Code: 12345<br />
    Date of Birth: 1/1/1900</p>

    <p>I&#8217;ve been tempted to use <code>&lt;dl&gt;</code>&#8216;s setting the &#8220;key&#8221; in a <code>&lt;dt&gt;</code> and the &#8220;value&#8221; inside the <code>&lt;dd&gt;</code>. For example:</p>

<pre><code>&lt;dl&gt;
  &lt;dt&gt;Name:&lt;/dt&gt;
  &lt;dd&gt;John Smith&lt;/dd&gt;
&lt;/dl&gt;</code></pre>

    <p>but I&#8217;m pretty sure that doesn&#8217;t mesh well with the actual intended use of the definition list. I feel like there ought to be someway to semantically relate the key to the value. Simply using just a span + class value doesn&#8217;t seem ideal. Suggestions?</p>
  </blockquote>

  <p>In <abbr>HTML</abbr>5, the specification of <code>&lt;dl&gt;</code> has been widened so that it&#8217;s now an association list:</p>
  
  <blockquote>
    <p>The <code>dl</code> 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 (<code>dt</code> elements) followed by one or more values (<code>dd</code> elements). Within a single <code>dl</code> element, there should not be more than one <code>dt</code> element for each name.</p>

    <p>Name-value groups may be terms and definitions, metadata topics and values, questions and answers, or any other groups of name-value data.</p>
    
    <footer>
      <cite><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-dl-element">WHATWG HTML specification</a></cite>
    </footer>
  </blockquote>
  
  <p>You can read more in our <a href="http://html5doctor.com/the-dl-element/">article on the <code>&lt;dl&gt;</code> element</a>.</p>

  <p>So you can use a <code>&lt;dl&gt;</code> there, but I&#8217;d probably use a <code>&lt;table&gt;</code>. And I&#8217;d definitely use the <code>&lt;time&gt;</code> element for the <abbr title="Date of Birth">DOB</abbr>.</p>

  <p>Cheers, Bruce.</p>
</section>

<section>
  <h2>E-commerce</h2>
  <p>Tom asked:</p>
  <blockquote>
    <p>I&#8217;ve read &#8220;Introducing HTML 5&#8243; and a fair few articles on the web, yet I have yet to come across anything that explains how to best take advantage of HTML 5 when displaying items in a shop category? It seems the new elements are designed for feeds such as blog posts or news.</p>
  </blockquote>
  
  <p>Let me answer your question with another question: Could you not, hypothetically, list shop products in a feed? Wouldn&#8217;t this make them similar to blog posts? In fact, they are very similar semantically as standalone entries within a larger system. From this, you can deduce that a shop product could be marked up in the same manner as a blog entry, or forum post, or feed item. In that case, <code>&lt;article&gt;</code> will commonly be an appropriate choice to wrap up your product.</p>
      
  <p><a href="http://html5doctor.com/the-article-element/" title="The article element | HTML5 Doctor">An <code>&lt;article&gt;</code> is a self-contained discrete item</a>. So a product could be wrapped in an <code>&lt;article&gt;</code> element (assuming that&#8217;s what you mean by &#8220;shop category&#8221;). There&#8217;s considerable discussion of that in our <a href="http://html5doctor.com/html5-simplequiz-1/">first Simplequiz</a>.</p>

  <p>To fully understand what <abbr>HTML</abbr>5 is trying to achieve, you have to think a little abstractly. But once you get used to that way of thinking, picking the right elements will be a breeze! Have a look at our <a href="http://html5doctor.com/happy-1st-birthday-us/#flowchart" title="Happy 1st Birthday us | HTML5 Doctor">Sectioning Element flowchart</a> for more info.</p>

  <p>Thanks, Mike.</p>
</section>

<section>
  <h2>Lightboxes and modal windows</h2>
  <p>James asked:</p>
  <blockquote>
    <p>What do you think the proper markup for lightboxes and modal dialog boxes (collectively, &#8220;popups&#8221;) would be? It&#8217;s important that the element be able to contain a <code>&lt;header&gt;</code> and <code>&lt;footer&gt;</code>. I don&#8217;t like <code>&lt;aside&gt;</code> or <code>&lt;figure&gt;</code> because the popup isn&#8217;t ancillary to the content; rather, it replaces or supplants the focus. I would opt for a <code>&lt;section&gt;</code>, but your flowchart indicates that they should have headings, which not all popups will. I&#8217;d love to hear your thoughts.</p>
  </blockquote>
  
  <p><abbr>IMO</abbr> the actual element depends on the contents. <code>&lt;figure&gt;</code> might be appropriate, as might <code>&lt;details&gt;</code> or <code>&lt;form&gt;</code> for a login form, and <code>&lt;aside&gt;</code> could also work. <code>&lt;section&gt;</code> doesn&#8217;t always need a heading, just usually.

  <p>There was <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=10645">a bug filed</a> to adopt a <code>modal</code> attribute — e.g., <code>&lt;section modal&gt;</code> — which would automatically make this happen. Also see <a href="http://dev.w3.org/html5/spec/Overview.html#dom-showmodaldialog"><code>showModalDialog()</code></a>.</p>

  <p>I know that Hixie wants this, but it&#8217;s probably for <abbr>HTML</abbr>next rather than <abbr>HTML</abbr>5: there&#8217;s enough to implement already! In an interview I did with him last year, I asked:</p>

  <p><i>Bruce</i>: What&#8217;s your fave feature that didn’t get into <abbr>HTML</abbr> 5 that you&#8217;d put into <abbr>HTML</abbr> 6?</p>

  <p><i>Hixie</i>: In-window modal dialogs or dialog box — the kind of prompt you get when the computer asks you a question and won&#8217;t let you do anything else until you answer the question. For instance, the window that comes up when you say &#8220;Save As…&#8221; is usually a modal dialog. Right now people fake it with divs and complicated styles and script. It would be neat to just be able to say &#8220;make this section a modal dialog&#8221;. Like showModalDialog(), but within the page instead of opening a new window with a new page. I&#8217;d add it to HTML 5, but there are so many new features already that we need to wait for the browsers to catch up.</p>

  <p><a href="http://www.webstandards.org/2009/05/13/interview-with-ian-hickson-editor-of-the-html-5-specification/">Full interview available at webstandards.org.</a></p>

  <p>Thanks, Bruce</p>
</section>

<section>
  <h2>Why do we need these new elements?</h2>
  <p>James asked:</p>
  <blockquote>
    <p>Doctor, doctor!</p>

    <p>I, like many, get very excited over all of the new &#8216;features&#8217; that HTML5 brings including Video and Canvas.</p>

    <p>What I can&#8217;t get my head around, is all of these new elements? I understand why <code>&lt;footer&gt;</code> <code>&lt;nav&gt;</code> <code>&lt;header&gt;</code> <code>&lt;section&gt;</code> have been introduced &#8212; to match what would typically common uses for divs, but I&#8217;m interested in knowing what usefulness this brings and when we will see the &#8216;positive results&#8217; of the use of these new elements.</p>

    <p>For example, when screen-scraping a page I can imagine a screenreader would find it useful to be able to identify, through element name, what part of the page is being read&#8230; is this the sole reason for these new elements (not saying that&#8217;s a bad thing!) and are any screen readers out there making use of this already that we can see? Are there other advantages?</p>

    <p>Many thanks, James</p>
  </blockquote>
  <p>Like you said, a screenreader is one beneficiary of the new elements, but a screenreader, at its core, is just a machine. Other machines can also take advantage of what <abbr>HTML</abbr>5 has to offer, from search engines to feed readers. While implementations are sparse at the moment, it&#8217;s up to people like you, me, my fellow doctors, and every other person taking an interest in <abbr>HTML</abbr>5 to do cool things with these new additions.</p>

  <p>So when will see &#8220;positive results&#8221;? When we all pull our fingers out and get cracking! Spread the word <img src='http://html5doctor.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

  <p>Regards, Mike</p>
</section>

<section>
  <h2>Optional subtitle</h2>
  <p>Björn asked:</p>
  <blockquote>
    <p>Hi doc,</p>

    <p>Is it ok to have an empty h2 tag or does it always have to contain text? I ask this question because some of my pages use a subtitle (h2) and others don&#8217;t need a subtitle.</p>

    <p>If not allowed, this would have weird consequences: the semantic meaning of an h3 tag on a page with an h2 subtitle atop would have the same hierarchical and semantic meaning as a h2 tag on a page without a subtitle, not to mention the CSS styling complications this would bring.</p>
  </blockquote>
  
  <p>I&#8217;d say you shouldn&#8217;t have an empty <code>&lt;h2&gt;</code> (with a few obscure exceptions, like a placeholder that&#8217;ll be filled by JavaScript), but it&#8217;s no problem because there’s a new <abbr>HTML</abbr>5 element that&#8217;ll solve your dilemma — <code>&lt;hgroup&gt;</code>. You can read a <a href="http://html5doctor.com/the-hgroup-element/">detailed write up in our <code>&lt;hgroup&gt;</code> article</a>, but in essence, when you&#8217;ve got a title and a subtitle next to each other, wrapping them with <code>&lt;hgroup&gt;</code> prevents the subtitle from getting in the document outline:</p>

<pre><code>&lt;article&gt;
  &lt;hgroup&gt;
    &lt;h1&gt;Title&lt;/h1&gt;
    &lt;h2&gt;Subtitle&lt;/h2&gt;
  &lt;/hgroup&gt;
  &lt;p&gt;...&lt;/p&gt;
  &lt;section&gt;
    &lt;h2&gt;Section title&lt;/h2&gt;
    &lt;p&gt;...&lt;/p&gt;
  &lt;/section&gt;
&lt;/article&gt;</code></pre>

  <p>It also means you can style the subtitle <code>&lt;h2&gt;</code> differently from following <code>&lt;h2&gt;</code> elements, for example:</p>

<pre><code>h2 {font-size: 1.75em;}
hgroup h2 {font-size: 1.125em;}</code></pre>

  <p>Finally, if you&#8217;re using <abbr>HTML</abbr>5&#8242;s sectioning elements (<code>&lt;article&gt;</code>, <code>&lt;section&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;aside&gt;</code>) and making sure that each title has a corresponding sectioning element wrapper (with the exception of subtitles inside <code>&lt;hgroup&gt;</code>), then you can use whatever heading levels you like and you&#8217;ll still get the correct hierarchical outline. It&#8217;s still best to make (and stick to) a logical visual hierarchy, from most to least important.</p>

  <p>peace &#8211; Oli</p>
</section>
  
<section>
  <h2>Got a question for us?</h2>
  <p>That wraps up this round of questions. If you&#8217;ve got a query about the <abbr>HTML</abbr>5 spec or how to implement it, you can <a href="http://html5doctor.com/ask-the-doctor/">get in touch</a> with us and we&#8217;ll do our best to help.</p>
</section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><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-hgroup-element/" rel="bookmark" class="crp_title">The hgroup element</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-7/" rel="bookmark" class="crp_title">Your Questions Answered #7</a></li><li><a href="http://html5doctor.com/your-questions-15/" rel="bookmark" class="crp_title">Your Questions #15</a></li></ul></div><p><a href="http://html5doctor.com/your-questions-18/" rel="bookmark">Your Questions 18</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on September 6, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-18/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Avoiding common HTML5 mistakes</title>
		<link>http://html5doctor.com/avoiding-common-html5-mistakes/</link>
		<comments>http://html5doctor.com/avoiding-common-html5-mistakes/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 13:38:05 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[figure]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[hgroup]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[nav]]></category>
		<category><![CDATA[section]]></category>

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

		<guid isPermaLink="false">http://html5doctor.com/?p=3055</guid>
		<description><![CDATA[<p>The clinic is packed this week with your HTML5 ailments! Today, we’ll discuss an HTML5 syntax dilemma, using sections within sections, link semantics, describing the contents of a figure, and marking up web app toolbars.</p>]]></description>
			<content:encoded><![CDATA[<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Doctor treating a patient illustration" class="alignright size-full wp-image-424" /> The clinic is packed this week with your <abbr>HTML</abbr>5 ailments! Today, we&#8217;ll discuss an <abbr>HTML</abbr>5 syntax dilemma, using sections within sections, <code>&lt;link&gt;</code> semantics, describing the contents of a figure, and marking up web app toolbars.</p>
<section>
<h2>HTML5 syntax dilemma</h2>
<p>Manuel asked:</p>
<blockquote>
<p>In theory, <abbr>HTML</abbr>5 syntax is very lazy but, in fact, when you write a <abbr>HTML</abbr>5 page you follow some conventions that originate in the <abbr>XHTML</abbr> era: lowercase code, double-quoted attribute values, properly closed elements, proper element nesting. While this practice is rational and admirable, some people take a further step towards a <abbr>XHTML</abbr>-style syntax: they don&#8217;t use attribute minimization and do terminate empty elements. Of course this further step is not necessary to write clear HTML5 code, but could be fostered if you look at the following points:</p>
<ol>
<li>it makes [it] easier to upgrade legacy <abbr>XHTML</abbr> code (which represents the bulk of the web even if it&#8217;s generally served as text-html) to <abbr>HTML</abbr>5 (it&#8217;s just a matter of doctype change)</li>
<li>it makes [an] easier the shift to <abbr>HTML</abbr>5 for web developers, since they are generally used to write <abbr>XHTML</abbr></li>
<li>it could set a coding standard in the field</li>
</ol>
<p>What do you think about it?</p>
</blockquote>
<p>I disagree. I think there&#8217;s nothing lazy about <abbr>HTML</abbr>5 syntax. You could say that it&#8217;s lazy that in <abbr>HTML</abbr> we write <code>&lt;hr&gt;</code> rather than <code>&lt;horzontalrule&gt;</code>, but the fact is, it&#8217;s a specified part of the language.</p>
<p>Furthermore, &#8220;legacy <abbr>XHTML</abbr>&#8221; code does not represent the bulk of the Web; 61% of the Web is <abbr>HTML</abbr>4 according to the <a href="http://dev.opera.com/articles/view/mama-w3c-validator-research-2/?page=2#doctype">Opera MAMA study in 2008</a>.</p>
<p>But it doesn&#8217;t matter. You say tom-<em>ay</em>-toes, I say to-<em>mah</em>-toes; you like <abbr>XHTML</abbr> syntax, I like <abbr>HTML</abbr> syntax. They&#8217;re all the same to a browser, if served as <code>text/html</code>.</p>
<p>Cheers, Bruce</p>
</section>
<section>
<h2>Sections within sections</h2>
<p>Corey asked:</p>
<blockquote>
<p>Don&#8217;t know if this has been asked before or not, as I couldn&#8217;t find anything to tell me otherwise. I read through the article and section information and understand more or less how they function, but I&#8217;m wondering if there is a case to be made about having a section within a section. Your article doesn&#8217;t really touch on whether this is appropriate or not.</p>
<p>The reason I ask is because I have a page that is broken into different parts (introduction, description, requirements, etc) that are all part of the same overall article. Now if I wanted to break down say, the requirements section into sub-sections (technical, stylistic, semantic, etc) would it be all right to wrap those sub sections in a section tag (that is within a section itself), assuming I put the correct header on it?</p>
<p>Thanks a bunch,</p>
</blockquote>
<p>Yes, you certainly can nest <code>&lt;section&gt;</code>s — in fact, that&#8217;s pretty much exactly what <code>&lt;section&gt;</code> is for! If you look at the source of some of our more recent articles — e.g., this article or <a href="http://html5doctor.com/microformats/">our microformats article</a> — you&#8217;ll notice how we&#8217;ve split the article into sections.</p>
<p>In theory, using nested sections means that we&#8217;ll be able to do away with <code>&lt;h2&gt;</code>–<code>&lt;h6&gt;</code>, since a new heading level is implied with each nested section. In practice, however, it&#8217;s not as simple as that, so we suggest sticking with the usual <code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code> heading structure even if you decide to nest sections.</p>
<p>For your example, this code would be entirely appropriate:</p>
<pre><code>&lt;article&gt;
  &lt;h1&gt;Article name&lt;/h1&gt;
  &lt;p&gt;...&lt;/p&gt;
  &lt;section&gt;
    &lt;h2&gt;Introduction&lt;/h2&gt;
    &lt;p&gt;...&lt;/p&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h2&gt;Description&lt;/h2&gt;
    &lt;p&gt;...&lt;/p&gt;
      &lt;section&gt;
        &lt;h3&gt;Technical&lt;/h3&gt;
        &lt;p&gt;...&lt;/p&gt;
      &lt;/section&gt;
      &lt;section&gt;
        &lt;h3&gt;Stylistic&lt;/h3&gt;
        &lt;p&gt;...&lt;/p&gt;
      &lt;/section&gt;
  &lt;/section&gt;
  &lt;section&gt;
    &lt;h2&gt;Requirements&lt;/h2&gt;
    &lt;p&gt;...&lt;/p&gt;
  &lt;/section&gt;
&lt;/article&gt;</code></pre>
<p>Each part of the <code>&lt;article&gt;</code> is wrapped in a <code>&lt;section&gt;</code>. The one exception might be the introduction, unless you are explicitly declaring a heading with it. You don&#8217;t always need a <code>&lt;header&gt;</code> element if it would only contain a single <code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code> element. In that case, the heading on it&#8217;s own will be fine. Bruce has <a href="http://www.brucelawson.co.uk/2010/html5-articles-and-sections-whats-the-difference/">a good post on the difference between articles and sections</a>.</p>
<p>Hope that helps, Rich</p>
</section>
<section>
<h2>Since we&#8217;re being semantic…</h2>
<p>Rob asked:</p>
<blockquote>
<p><abbr>HTML</abbr>5 is working towards being more semantic, but I don&#8217;t think the <code>&lt;link/&gt;</code> tag is semantic at all…especially for stylesheets!  Has anyone ever suggested changing the specification for the <code>&lt;style&gt;</code> tag to have an &#8216;src&#8217; attribute that would point to the <abbr>CSS</abbr> file? Current:</p>
<pre><code>&lt;link rel="stylesheet" href="style.css" /&gt;</code></pre>
<p>Suggestion:</p>
<pre><code>&lt;style src="style.css"&gt;&lt;/style&gt;</code></pre>
</blockquote>
<p>I think most implementors would say that the current way works well enough. Breaking backwards compatibility for the sake of theoretical purity was where <abbr>XHTML</abbr> 2 was heading before it was finally curtailed. <abbr>HTML</abbr>5 takes stock of where we are, warts and all, and builds on that. (I feel your pain: I always want <code>&lt;img&gt;</code> to be <code>&lt;image&gt;</code>.)</p>
<p>Cheers, Bruce</p>
</section>
<section>
<h2>Describing the content of <code>&lt;figure&gt;</code></h2>
<p>Sverri asked:</p>
<blockquote>
<p>A lot of things can be presented as figures (everything from a simple quote to an information-dense canvas). The first thing that came to my mind was using e.g. a &#8220;type&#8221; attribute. For example:</p>
<pre><code>&lt;figure type="code css"&gt;
  &lt;figcaption&gt;Styling p tags&lt;/figcaption&gt;
  &lt;code&gt;p { margin-bottom: 1em }&lt;/code&gt;
&lt;/figure&gt;</code></pre>
<p>That would be a dead simple way of succinctly telling user agents, search engines, etc. what kind of content they can expect to find in the figure. However, since this is not valid <abbr>HTML</abbr>5 (as far as I know) how would you recommend describing the contents of a figure, so as to make it more accessible to non-human agents?</p>
<p>Thank you.</p>
</blockquote>
<p>Bruce replied:</p>
<p>What would be the purpose of doing so? For example, it&#8217;s easy for a non-human agent to see that your example contains code, or that:</p>
<pre><code>&lt;figure&gt;
  &lt;video&gt;...&lt;/video&gt;
  &lt;figcaption&gt;...&lt;/figcaption&gt;
&lt;/figure&gt;</code></pre>
<p>contains video, or that:</p>
<pre><code>&lt;figure&gt;
  &lt;img /&gt;
  &lt;figcaption&gt;...&lt;/figcaption&gt;
&lt;/figure&gt;</code></pre>
<p>contains an image. So I&#8217;m not sure of the use case for a type attribute.</p>
<p>Sverri then responded:</p>
<blockquote>
<p>The way I think about this is that figures are images of sorts, or embedded content. A &#8220;type&#8221; attribute (or perhaps a more aptly named &#8220;of&#8221; attribute) would be the equivalent of the &#8220;alt&#8221; attribute of <code>img</code>. It is extra information, and as such would not always be needed, but sometimes it can be an important part in how you present the content.</p>
<p>As for use cases:</p>
<ul>
<li>Aiding search engines better understand the content</li>
<li>Browsers can use such information to make browsing the internet richer</li>
</ul>
<p>I realize that you can use some other way of describing the content, such as titles, itemscopes or other ways of adding metadata. A dedicated, but optional, attribute for this would not be such a bad idea in my opinion.</p>
<p>To sum up, I suppose what I am getting at is that content in a <code>figure</code> is not always so well defined on its own.  A snippet of code, for example, is given more meaning if it is in a context, such as &#8220;css&#8221;, &#8220;algorithm&#8221; or &#8220;while loop&#8221;.</p>
<p>I hope I am being clear enough in what I am saying.</p>
</blockquote>
<p>Bruce followed up once more:</p>
<p>You are clear. There have been many such discussions during the development of <abbr>HTML</abbr>5 (and preceding versions of <abbr>HTML</abbr>). For example, why not have a <code>&lt;name&gt;</code> element for marking up people&#8217;s names, analogous to <code>&lt;time&gt;</code>? Why not have <code>&lt;geo&gt;</code> or <code>&lt;place&gt;</code> or <code>&lt;location&gt;</code>?</p>
<p>The use cases you describe (aiding search engines and browsers) are equally applicable.</p>
<p>But it comes down to two factors:</p>
<p>First, <abbr>HTML</abbr> is not a specialised language. It&#8217;s a generalised language, and there are some cases that can&#8217;t be marked up with the existing crop of elements. (There are already over a hundred.)</p>
<p>Second is that minting new elements and attributes isn&#8217;t &#8220;free&#8221;. It&#8217;s more for authors to remember (and get wrong), it bloats parsers in browsers, and it makes regression testing harder. So if a new addition to the language doesn&#8217;t solve a very common problem, it isn&#8217;t added to the language.</p>
<p>As you said, microdata/microformats/RDFa can be used to extend the language for specialised cases.</p>
<p>Thanks, Bruce</p>
</section>
<section>
<h2>Web app buttons and toolbars: anchors, buttons, or commands?</h2>
<p>Christian asked:</p>
<blockquote>
<p>If you&#8217;re creating a toolbar for a web app, or perhaps even a &#8220;Share this page&#8221; widget, should one use anchors, buttons or commands?</p>
</blockquote>
<p>A toolbar should be <abbr>HTML</abbr>5 <code>&lt;menu&gt;</code> with nested <code>&lt;command&gt;</code>s, but browser support is zilch. I&#8217;d use a list of buttons, personally. I think <code>&lt;button&gt;</code> is the right element to perform tasks that might need an &#8220;undo&#8221;, like &#8220;Tweet This&#8221; or &#8220;Delete Document&#8221;.</p>
<p>Bruce</p>
</section>
<section>
<h2>Got a question for us?</h2>
<p>That wraps up this round of questions. If you&#8217;ve got a query about the <abbr>HTML</abbr>5 spec or how to implement it, you can <a href="http://html5doctor.com/ask-the-doctor/">get in touch</a> with us and we&#8217;ll do our best to help.</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-5/" rel="bookmark" class="crp_title">Your Questions Answered #5</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/your-questions-answered-8/" rel="bookmark" class="crp_title">Your Questions Answered #8</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-6/" rel="bookmark" class="crp_title">Your Questions Answered #6</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/your-questions-17/" rel="bookmark">Your Questions #17</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on April 19, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-17/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Your Questions #16</title>
		<link>http://html5doctor.com/your-questions-16/</link>
		<comments>http://html5doctor.com/your-questions-16/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 14:30:38 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[aside]]></category>
		<category><![CDATA[b]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[i]]></category>
		<category><![CDATA[nav]]></category>
		<category><![CDATA[section]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2748</guid>
		<description><![CDATA[<p>The clinic is getting busy with more HTML5 ailments! This week, we'll cover the separation of formatting and content, custom elements, using aside for social links, sections with no visible titles, and canvas in the DOM.</p>]]></description>
			<content:encoded><![CDATA[<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Doctor treating a patient illustration" class="alignright size-full wp-image-424" /> The clinic is getting busy with more <abbr>HTML</abbr>5 ailments! This week, we&#8217;ll cover the separation of formatting and content, custom elements, using <code>&lt;aside&gt;</code> for social links, sections with no visible titles, and <code>&lt;canvas&gt;</code> in the <abbr>DOM</abbr>.</p>
<section>
<h2>Separation of formatting and content</h2>
<p>Graham asked:</p>
<blockquote>
<p>When I first started learning html and <abbr>CSS</abbr> I was constantly told not to use <code>b</code> or <code>i</code> tags as the idea was to completely separate formatting from content. Is this now not the case?</p>
</blockquote>
<p>In <abbr>HTML</abbr> 4 (and <abbr>XHTML</abbr> 1.x), the elements <code>&lt;b&gt;</code> and <code>&lt;i&gt;</code> (plus some others) were presentational — they only had visual meaning. This doesn’t work so well for blind users, for example.</p>
<p>In <abbr>HTML</abbr>5, presentational elements have either been cut or, as in the case of <code>&lt;b&gt;</code> and <code>&lt;i&gt;</code>, given semantic meanings to make them media-independent. You can find out more here: <a href="http://html5doctor.com/i-b-em-strong-element/">The <code>&lt;i&gt;</code>, <code>&lt;b&gt;</code>, <code>&lt;em&gt;</code>, and <code>&lt;strong&gt;</code> elements</a> and <a href="http://html5doctor.com/small-hr-element/">The <code>&lt;small&gt;</code> and <code>&lt;hr&gt;</code> elements</a>.</p>
<p>So to directly answer your question, in <abbr>HTML</abbr>5, <code>&lt;b&gt;</code> and <code>&lt;i&gt;</code> are now content (semantic), not formatting (presentational).</p>
<p>peace &#8211; Oli</p>
</section>
<section>
<h2>Custom elements</h2>
<p>Eric asked:</p>
<blockquote>
<p>It is possible to use custom elements in <abbr>HTML</abbr>5 to be more semantic; however, is it ill-advised? For example:</p>
<p>    <code>
<pre>&lt;footer id="page-footer"&gt;
&lt;copyright&gt;Copyright ©...&lt;/copyright&gt;
&lt;/footer&gt;</pre>
<p></code></p>
</blockquote>
<p>Umm, no, <abbr>HTML</abbr>5 doesn&#8217;t allow &#8220;custom elements&#8221;. While browsers will try to recover gracefully if you do this, making stuff up is definitely ill-advised — something like <code>&lt;copyright&gt;</code> will have no meaning for browsers and could lead to problems in <abbr>IE</abbr>.</p>
<p>If you want an element for a copyright statement or other short legalese, there’s already a perfectly <a href="http://html5doctor.com/small-hr-element/">good one in <code>&lt;small&gt;</code></a>.</p>
<p>If you can’t find a more semantically appropriate element, use <code>&lt;span&gt;</code> for phrasing (inline) content, <code>&lt;p&gt;</code> for a block of phrasing content, or <code>&lt;div&gt;</code> for flow (block-level) content, and add a class name that indicates the semantics — e.g. <code>&lt;span class="lorem"&gt;Lorem ipsum&lt;/span&gt;</code>.</p>
<p>Hope that helps!</p>
<p>peace &#8211; Oli</p>
</section>
<section>
<h2>Marking up social links</h2>
<p>A reader asked:</p>
<blockquote>
<p>Could a list of share icons (twitter, facebook, etc) be considered a candidate for use of the nav element? and do links in a <code>nav</code> element <strong>have to be</strong> into the same domain name&#8221;?</p>
</blockquote>
<p><code>&lt;nav&gt;</code> is for navigation around your content. On my personal site, I have a link to my Flickr photostream marked up in the same container as links to my own contact page, etc. I think the link to Flickr is conceptually no different to navigation within my personal site: it&#8217;s all <em>my</em> content. If my photos were on my own domain (as they used to be), I wouldn&#8217;t hesitate to include them in <code>&lt;nav&gt;</code>, and I wouldn&#8217;t hesitate to include this same content within <code>&lt;nav&gt;</code> today.</p>
<p>A list of share icons isn&#8217;t <code>&lt;nav&gt;</code> for two separate reasons.</p>
<p>First, they aren&#8217;t meant to take you somewhere else. They&#8217;re designed to perform an action of tweeting/&#8221;liking&#8221; a link to a page.</p>
<p>Second, and most importantly, they&#8217;re not navigation around your content. As the <a href="http://dev.w3.org/html5/spec/sections.html#the-nav-element">spec says</a> <q>&#8220;Not all groups of links on a page need to be in a nav element — only sections that consist of major navigation blocks are appropriate for the nav element.&#8221;</q></p>
<p>As a list of share icons is tangential to your content, I&#8217;d probably use <a href="http://dev.w3.org/html5/spec/sections.html#the-nav-element">the <code>&lt;aside&gt;</code> element</a>: <q>&#8220;The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. Such sections are often represented as sidebars in printed typography&#8221;</q>. For more details, check out our <a href="http://html5doctor.com/aside-revisited/"><code>&lt;aside&gt;</code> revisited</a> article.</p>
<p>Social links are the kind of thing that could be cut from a feed reader without diminishing the value of the content. As an additional note, remember that you can also place an <code>&lt;aside&gt;</code> at the end of an article, like a footer. In spite of its name, <code>&lt;aside&gt;</code> doesn&#8217;t have to be a sidebar.</p>
<p>Thanks, Bruce and Mike</p>
</section>
<section>
<h2>Sections with no visible titles</h2>
<p>Francesco asked:</p>
<blockquote>
<p>I have some divs, in a page, that semantically would make more sense as sections as there are natural headings for them, but they&#8217;re not written *inside* them, they&#8217;re outside. There are tabs to switch the visibility of these sections, and the tab navigation is on their left&#8230; so the actual title is only there, and not repeated inside of the sections. But besides that they really are sections&#8230; they even had &#8220;class=section&#8221; in the old version. <img src='http://html5doctor.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>What would the best solution be? Put an <code>h1</code> in there with <code>display:none</code>? It would make the outline correct, but it looks like a hack.</p>
</blockquote>
<p>You should reorganise your markup to ensure the headings are within the section. Then you can use some <abbr>CSS</abbr> positioning trickery to move them into place. Don&#8217;t use <code>display:none</code>, though, as that&#8217;s invisible to everyone, including assistive technologies like screen readers.</p>
<p>Cheers, Rich</p>
</section>
<section>
<h2><abbr>HTML</abbr>5 <code>&lt;canvas&gt;</code> and the <abbr>DOM</abbr></h2>
<p>Elango asked:</p>
<blockquote>
<p>Is it possible to get the elements i have drawn into the canvas using some API. Say for eg i draw 2 circle and 2 lines is that possible for me to get these information from Canvas by using DOM API&#8217;s</p>
</blockquote>
<p>No. Think of a canvas like a canvas you would physically paint on. If you paint a red stroke and then paint over that in blue, you can&#8217;t get back to the original red stroke. The canvas <abbr>API</abbr> works the same way: once your <strong>pixels</strong> are committed, you can&#8217;t go back.</p>
<p>You want <abbr>SVG</abbr> (or try out <a href="http://raphaeljs.com">Raphaël</a>).</p>
<p>Cheers, Remy</p>
</section>
<section>
<h2>Got a question for us?</h2>
<p>That wraps up this round of questions. If you&#8217;ve got a query about the <abbr>HTML</abbr>5 spec or how to implement it, you can <a href="http://html5doctor.com/ask-the-doctor/">get in touch</a> with us and we&#8217;ll do our best to help.</p>
</section>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<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/your-questions-answered-7/" rel="bookmark" class="crp_title">Your Questions Answered #7</a></li>
<li><a href="http://html5doctor.com/your-questions-14/" rel="bookmark" class="crp_title">Your Questions #14</a></li>
<li><a href="http://html5doctor.com/your-questions-15/" rel="bookmark" class="crp_title">Your Questions #15</a></li>
<li><a href="http://html5doctor.com/your-questions-13/" rel="bookmark" class="crp_title">Your Questions #13</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/your-questions-16/" rel="bookmark">Your Questions #16</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on March 1, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-16/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Your Questions #15</title>
		<link>http://html5doctor.com/your-questions-15/</link>
		<comments>http://html5doctor.com/your-questions-15/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 14:30:23 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[figcaption]]></category>
		<category><![CDATA[figure]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[hgroup]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[pre]]></category>
		<category><![CDATA[wikipedia]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2744</guid>
		<description><![CDATA[<p>The clinic is busy as ever with more <abbr>HTML</abbr>5 ills. This week, we'll cover marking up Wikipedia infoboxes, anchors in <code>&#60;hgroup&#62;</code>, <code>&#60;figure&#62;</code> for avatars, header(s), and how to use <code>&#60;code&#62;</code> and <code>&#60;pre&#62;</code>.</p>]]></description>
			<content:encoded><![CDATA[<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Doctor treating a patient illustration" class="alignright size-full wp-image-424" /> The clinic is busy as ever with more <abbr>HTML</abbr>5 ills. This week, we&#8217;ll cover marking up Wikipedia infoboxes, anchors in <code>&lt;hgroup&gt;</code>, <code>&lt;figure&gt;</code> for avatars, header(s), and how to use <code>&lt;code&gt;</code> and <code>&lt;pre&gt;</code>.</p>

<section>
  <h2>Wikipedia Infoboxes</h2>
  <p>Andrés asked:</p>
  <blockquote>
    <p>Hello. I want to ask how I can code some stuff based on Wikipedia infoboxes with <abbr>HTML</abbr>5, which most of the time uses tables. I think that all of these can be surrounded by a figure tag, but I&#8217;m not sure about the subtleties.</p>

    <p>Reference page: <a href="http://en.wikipedia.org/wiki/Help!_%28album%29">http://en.wikipedia.org/wiki/Help!_%28album%29</a>. It has a main infobox that:</p>

    <ul>
    	<li>Has a heading</li>
    	<li>Has a thumbnail image</li>
    	<li>Has 3 sections each separated by a faux table heading:
    		<ul>
    			<li>One that has a table with two columns, one with keys and other with labels, which I believe that can be done better with definition list but not sure if table is suited too</li>
    			<li>One that has a list of links of magazines that have reviewed the disc. I believe it is fine as is coded but still</li>
    			<li>One with a &#8220;chronology&#8221;, which is like a navigation menu in a table with the previous, current (no link) and next installment. Not idea if there&#8217;s an ideal way to markup it</li>
    		</ul>
    	</li>
    </ul>

    <p>There&#8217;s a 2nd infobox that feature a long list of links of related contents divided by some kind of table headings. I suppose it may better done by lists but there&#8217;s may be another approach. The 3rd infobox repeats the chronology noted above.</p>
  </blockquote>
  
  <p>It&#8217;s a blessing and curse of <abbr>HTML</abbr> that there is often more than one correct answer. This is even more true with <abbr>HTML</abbr>5. Let&#8217;s look at the Help! album page:</p>

  <ul>
  	<li>Is the infobox essential to understanding? If yes, use <code>&lt;figure&gt;</code>; if no, use <code>&lt;aside&gt;</code> (inside <code>&lt;article&gt;</code>). If this data is just a summary of information already in the article, <code>&lt;aside&gt;</code> would be appropriate. If it contains unduplicated data, I prefer <code>&lt;figure&gt;</code>. I don’t think <code>&lt;table&gt;</code> is the best container element for the infobox.</li>
  	<li>For the “studio album” details section, either <code>&lt;dl&gt;</code> or <code>&lt;table&gt;</code> would be appropriate.</li>
  	<li>“Professional reviews” and “chronology” both look like lists, although either could also be a table.</li>
  	<li>I actually find the chronology formatting quite strange, as it’ll only work well for 1–3 items. Assuming this would be used for a full chronology, an ordered list would be more suitable. I guess that this is <em>only</em> to list the previous and next albums (a partial chronology). I don’t think it’s suitable for <code>&lt;nav&gt;</code> as the Beatles released more than three albums (but might be if all albums were listed). It’d be good to use <code>rel="previous"</code> and <code>rel="next"</code> attributes on these links.</li>
  	<li>The blue background titles would be best represented by <code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code>
  titles, ideally titling each <code>&lt;section&gt;</code>.</li>

  <p>I&#8217;m guessing the second infobox you refer to is the large table of links at the bottom of the page. This seems appropriate as a series of inline lists (ordered by time or alphabetically) in a table.</p>

  <p>I&#8217;m also guessing the third infobox you refer to is the &#8220;US Release&#8221; one that uses the same template as the first. The first infobox notes apply here too.</p>

  <p>Peace — Oli</p>
</section>
    
<section>
	<h2>No anchor elements allowed in <code>&lt;hgroup&gt;</code> elements</h2>
	<p>Daniel asked:</p>
	<blockquote>
		<p>Consider the following code:<p>

<pre><code>&lt;hgroup&gt;
&lt;a href="/"&gt;
  &lt;h1&gt;Title&lt;/h1&gt;
  &lt;h2&gt;Sub Title&lt;/h2&gt;
&lt;/a&gt;
&lt;/hgroup&gt;</code></pre>

    <p>When using <a href="http://html5.validator.nu/">http://html5.validator.nu/</a> to validate my page, it says that this is invalid &#8220;Error: Element a  not allowed as child of element hgroup  in this context.&#8221;</p>

    <p>I know that this validator is in beta (at least I think so), so maybe it&#8217;s wrong, but would you tell me if this is really valid or invalid? If it is invalid, would putting the anchor tags inside the heading tags fix it (despite having to use more markup <img src='http://html5doctor.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
    </p>
	</blockquote>
	
	<p>This example is in fact invalid. Only <code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code> elements can be a child of <code>&lt;hgroup&gt;</code>.</p>

	<p>You can get around it using <a href="http://html5doctor.com/block-level-links-in-html-5/">block-level links</a> like so (but bear in mind some browsers have trouble with block-level links):</p>

<pre><code>&lt;a href="/"&gt;
&lt;hgroup&gt;
  &lt;h1&gt;Title&lt;/h1&gt;
  &lt;h2&gt;Sub Title&lt;/h2&gt;
&lt;/hgroup&gt;
&lt;/a&gt;</code></pre>

  <p>Hope that helps.</p>

  <p>Rich</p>
</section>

<section>
	<h2>Using <code>&lt;figure&gt;</code> and <code>&lt;figcaption&gt;</code> as the avatar/id in a blog comment</h2>
	<p>BigAB asked:</p>
	<blockquote>
		<p>Would this be a proper use of the figure and figcaption tags: representing the common case of avatar/username on comments (or forum entries) as a figure? Example:</p>
<pre><code>&lt;article class="comment"&gt;
   &lt;h4&gt;Comment on &lt;a href="/the-blog-article"&gt;The Blog Article&lt;/a&gt;&lt;/h4&gt;
   &lt;figure&gt;
       &lt;img class="avatar" src="/my-avatar" /&gt;
       &lt;figcaption&gt;&lt;a rel="nofollow" href="http://my-website.exp"&gt;My Name&lt;/a&gt;&lt;/figcaption&gt;
   &lt;/figure&gt;
   &lt;p&gt;I am commenting on our blog article. This is my comment. I have much to comment on and am doing so in this comment.&lt;/p&gt;
   &lt;p&gt;Thank you for letting me comment here.  I think it good that we can comment.  Feel free to comment on my comment.&lt;/p&gt;
&lt;/article&gt;</code></pre>
	</blockquote>

	<p>Doesn&#8217;t feel right to me. The spec says this:</p>
	
	<blockquote>
	  <p>&#8220;The figure element represents some flow content, optionally with a caption, that is self-contained and is typically referenced as a single unit from the main flow of the document.</p>
    
    <p>The element can thus be used to annotate illustrations, diagrams, photos, code listings, etc, that are referred to from the main content of the document, but that could, without affecting the flow of the document, be moved away from that primary content, e.g. to the side of the page, to dedicated pages, or to an appendix.&#8221;</p>
    
    <footer>
      <cite><a href="http://www.w3.org/TR/html5/grouping-content.html#the-figure-element">W3C Specification</a></cite>
    </footer>
  </blockquote>

  <p>By &#8220;referred to&#8221;, I understand that to be &#8220;See figure 9&#8243;, but your example doesn&#8217;t do that. Personally, I&#8217;d just write:</p>

  <pre><code>&lt;a href="#"&gt;&lt;img alt="Bob's homepage"&gt;Bob Smith&lt;/a&gt;</code></pre>

  <p>Cheers, Bruce</p>
</section>

<section>
	<h2>HTML5 Header</h2>
	<p>Josh asked:</p>
	<blockquote>
		<p>I have read up a lot on the header element, and nesting numbered headers inside the hgroup element, and so forth. I&#8217;ve put a lot of the things I&#8217;ve seen on HTML5Doctor.com into practice on my own site, but was wondering if I can actually put the numbered header anywhere in the header, instead of having the numbered header (eg, h1-h6) first.</p>

    <p>I was also wondering if putting links inside an h1-h6 itself would actually damage either page rank or usability. I mean, I don&#8217;t imagine how it would, but I like to be very careful, almost too careful with how I do things. I do auto-validations of all my markup constantly, and do manual validation once in a while. So, I&#8217;m a little OCD when it comes to items such as the header. Of course, putting the a element around the header itself may not hurt either &#8211; but like I said, I love to be careful.</p>

    <p>Plus, great work on the site and the organization, folks! Some friends and myself make some articles on topics such as CSS and XHTML, more-recently HTML5, and it&#8217;s refreshing to come here to see a view from some real experts!</p>
	</blockquote>
	
	<p>Thanks for your e-mail.</p>
	
  <ul>
  	<li><code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code> elements can go anywhere inside <code>&lt;header&gt;</code>, although we advise you to mark up your content first before thinking about <abbr>CSS</abbr>, so your page makes sense even without <abbr>CSS</abbr>.</li>
  	<li>If you have more than one <code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code> as children of a <code>&lt;header&gt;</code>, wrap them in <code>&lt;hgroup&gt;</code>. If there’s nothing else in the <code>&lt;header&gt;</code>, just use the <code>&lt;hgroup&gt;</code> and not the <code>&lt;header&gt;</code>.</li>
  	<li>If you only have one <code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code> and no other heading content, you don’t need either <code>&lt;hgroup&gt;</code> or <code>&lt;header&gt;</code>, although they might still be useful for a <abbr>CMS</abbr> template (where more stuff might be inserted) or as <abbr>CSS</abbr> hooks.</li>
  	<li>Links inside <code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code> don’t affect page ranking or usability in isolation (but might affect usability if, for example, the link is to the current page).</li>
  	<li>You can use block-level links around a <code>&lt;header&gt;</code> or <code>&lt;hgroup&gt;</code>, but test and be careful of Firefox’s <a href="http://remysharp.com/2009/08/10/defining-the-vomit-bug/">vomit</a> <a href="http://oli.jp/2009/html5-block-level-links/">bug</a>.</li>
  </ul>

  <p>Finally, while we applaud your studious approach to coding, do keep in mind that <abbr>HTML</abbr> is quite forgiving <img src='http://html5doctor.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  As long as you validate occasionally and follow the spec, you’ll be fine. The web stack is a deep rabbit hole to go down, so while it’s great to do the best you possibly can, we also prescribe going outside once in a while <img src='http://html5doctor.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

  <p>Peace — Oli</p>
</section>

<section>
	<h2><code>&lt;code&gt;</code> vs <code>&lt;pre&gt;</code></h2>
	<p>Daniel asked:</p>
	<blockquote>
		<p>Dear HTML5doctors,</p>

    <p>How should I markup code example correctly? I have some that are inline inside my text, I think that&#8217;s <code>code</code> then, but others are multi lined. I need them to be white-spaced correctly as they would get them with <code>pre</code>, but isn&#8217;t that semantically wrong?</p>

    <p>Or do I put <code>&lt;code&gt;</code> inside <code>&lt;pre&gt;</code>? <code>&lt;pre&gt;</code> inside <code>&lt;code&gt;</code>? Or is <code>&lt;pre&gt;</code> to <code>&lt;code&gt;</code> as <code>&lt;b&gt;</code> is to <code>&lt;strong&gt;</code>?</p>

    <p>Many thanks</p>
	</blockquote>
	
	<p>For inline code, just use <code>&lt;code&gt;...&lt;/code&gt;</code>, a phrasing (inline) element. For multi-line code, use <code>&lt;pre&gt;&lt;code&gt;...&lt;/code&gt;&lt;/pre&gt;</code>. <code>&lt;pre&gt;</code> is a flow (block-level) element. Finally, the entities &amp;lt; and &amp;gt; map to &lt; and &gt;, which you’ll need to escape inside any <abbr>HTML</abbr> code snippets (although you only really need to do the first one).</p>

  <p>Peace — Oli</p>
</section>

<section>
	<h2>Got a question for us?</h2>
	<p>That wraps up this round of questions. If you&#8217;ve got a query about the <abbr>HTML</abbr>5 spec or how to implement it, you can <a href="http://html5doctor.com/ask-the-doctor/">get in touch</a> with us and we&#8217;ll do our best to help.</p>
</section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/your-questions-14/" rel="bookmark" class="crp_title">Your Questions #14</a></li><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/your-questions-answered-7/" rel="bookmark" class="crp_title">Your Questions Answered #7</a></li><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/avoiding-common-html5-mistakes/" rel="bookmark" class="crp_title">Avoiding common HTML5 mistakes</a></li></ul></div><p><a href="http://html5doctor.com/your-questions-15/" rel="bookmark">Your Questions #15</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on January 14, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-15/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Your Questions #14</title>
		<link>http://html5doctor.com/your-questions-14/</link>
		<comments>http://html5doctor.com/your-questions-14/#comments</comments>
		<pubDate>Fri, 26 Nov 2010 14:30:07 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[aside]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[nav]]></category>
		<category><![CDATA[section]]></category>
		<category><![CDATA[stylesheets]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2543</guid>
		<description><![CDATA[<p>The clinic is getting busy with more <abbr>HTML</abbr>5 ailments. This week, we'll cover questions about aside, blogging platforms, stylesheet links, id attribute validation and a mammoth semantic journey.</p>]]></description>
			<content:encoded><![CDATA[<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Doctor treating a patient illustration" class="alignright size-full wp-image-424" /> The clinic is getting busy with more <abbr>HTML</abbr>5 ailments. This week, we&#8217;ll cover questions about <code>&lt;aside&gt;</code>, blogging platforms, stylesheet links, <code>id</code> attribute validation, and take a mammoth semantic journey.</p>

<section>
  <h2>Aside question</h2>
  <p>Lukasz asked:</p>
  <blockquote>
    <p>I wonder if such use of aside tag inside <code>section</code> would be correct:</p>
<pre><code>&lt;section id="about"&gt;
  &lt;h1&gt;about me&lt;/h1&gt;
  &lt;p&gt;blablabla&lt;/p&gt;
  &lt;aside&gt;
    &lt;h2&gt;you can also find me on:&lt;/h2&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href="#"&gt;twitter&lt;/a&gt;&lt;/li&gt;
      ...
    &lt;/ul&gt;
  &lt;/aside&gt;
&lt;/section&gt;</code></pre>
    <p>Thanks in advance for any help and keep up the good work!</p>
  </blockquote>
  <p>Hard to give definitive advice without seeing the whole page, but it seems fine to me. See <a href="http://html5doctor.com/aside-revisited/">Mike&#8217;s article on <code>&lt;aside&gt;</code></a>.</p> 

	<p>In general, use <code>&lt;aside&gt;</code> for a section of a page that consists of content that is tangentially <em>related to</em> but <em>separate from</em> the surrounding content. In print, this would be a sidebar, pull-quote, or footnote. On a weblog article, this could be article metadata in the margin or the comments section.</p>

	<p>If your social network links are main content, then <code>&lt;aside&gt;</code> isn&#8217;t the element (maybe <code>&lt;section&gt;</code>, maybe <code>&lt;nav&gt;</code>). If they&#8217;re just related content (i.e., they could be omitted when showing this page in a feed reader), then <code>&lt;aside&gt;</code> is a good choice.</p>

	<p>peace &#8211; Oli</p>
</section>

<section>
  <h2>Blogging services</h2>
  <p>Patrick asked:</p>
  <blockquote>
    <p>Do you have any suggestions to people implementing <abbr>HTML</abbr>5 on blogging services like Tumblr? The last time I checked, there are problems making <abbr>HTML</abbr>5 blogs on these sites:</p>
    <ul>
      <li>Tumblr &#8211; inserted iframe breaks <abbr>HTML</abbr>5 conformance</li>
      <li>Posterous &#8211; no Javascript allowed at the moment (according to their doc)</li>
      <li>Blogger &#8211; it doesn&#8217;t preserve my <abbr>HTML</abbr>5 DOCTYPE</li>
    </ul>
		<p>Are there blogging services that don&#8217;t mess with the <abbr>HTML</abbr>5 markup?</p>
  </blockquote>
  <p>I used to use Tumblr, and you can use <abbr>HTML</abbr>5 in your templates. But any new <abbr>HTML</abbr>5 elements (e.g., <code>&lt;section&gt;</code>) in your articles get munged, even
using the “Raw <abbr>HTML</abbr>” setting. Unfortunately, I think that managed blogging services will probably be a little slow to adopt <abbr>HTML</abbr>5 (= fix the <abbr>HTML</abbr>5 errors they/their tools have), and you&#8217;ll have to use your own <abbr>CMS</abbr> for that level of control.</p>

	<p>You can of course build your own theme for something like WordPress, and a little birdie did tell me that the latest version of WordPress has <em>some</em> <abbr>HTML</abbr>5 in its default template, so this might carry over into their hosted service. If you can&#8217;t wait and don&#8217;t have a server, remember that <abbr>HTML</abbr>5 is a sliding scale — I was using <code>&lt;div class="section"&gt;</code> with Tumblr for a while.</p>

	<p>peace &#8211; Oli</p>
</section>

<section>
  <h2>Link stylesheet</h2>
  <p>Steve asked:</p>
  <blockquote>
    <p>Hello, can we get rid of type=&#8221;text/css&#8221; when declaring a link rel=&#8221;stylesheet&#8221;?</p>

		<p>Thank you and long live the web.</p>
  </blockquote>
  <p>You certainly can do that. Same with including JavaScript:</p>

<pre><code>&lt;link rel="stylesheet" media="screen, projection" href="http://html5doctor.com/css/style.css"&gt;
&lt;script src="http://html5doctor.com/js/html5.js"&gt;&lt;/script&gt;</code></pre>

  <p>Thanks, Tom</p>
</section>

<section>
  <h2>ID attribute validation</h2>
  <p>Andrés asked:</p>
  <blockquote>
    <p>Does the id attribute allows to begin with a number or a hyphen, unlike previous specs? Is there any set of character that aren&#8217;t allowed, besides space character?</p>
  </blockquote>
  <p>There are three rules for the value of the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#the-id-attribute">ID attribute</a>:</p>

  <ol>
    <li>It must be at least one character long,</li>
    <li>it must contain no space characters, and</li>
    <li>it must be unique within the page.</li>
  </ol>

	<p>So a hyphen would be valid as an ID value. It validates too. However, you may run into legacy stuff that hasn&#8217;t been updated yet (<abbr>HTML</abbr> Tidy, <abbr>WYSIWYG</abbr> plugins for a <abbr>CMS</abbr>, etc), so I&#8217;d advise testing within your workflow and in a browser (no idea if <abbr>IE</abbr> would barf on that, and it wouldn’t surprise me if it did).</p>

	<p>peace &#8211; Oli</p>
</section>

<section>
  <h2>I&#8217;m so confused &#8211; article, header, footer, nav?</h2>
  <p>Benjamin asked:</p>
  <blockquote>
    <p>Hey Doctor(s), I&#8217;m so confused right now.</p>

		<p>I&#8217;ve been trying to implement <abbr>HTML</abbr>5 for my new blog and <abbr>CMS</abbr>, but having difficulties trying to figure out where advanced content should go. All the demonstrations and examples about <abbr>HTML</abbr>5 are over-simplified and just don&#8217;t include any real world information. For example, an article typically includes (in no particular order):</p>

    <ul>
      <li>Article
        <ul>
          <li>Title</li>
          <li>Tagline</li>
          <li>Tags</li>
          <li>Avatar</li>
          <li>Content</li>
          <li>Links to child articles (eg. download, docs, demo)
            <ul>
              <li>Link Title</li>
              <li>Link Avatar</li>
              <li>Link Author Name</li>
            </ul>
          </li>
          <li>Links to recommended articles (related content)
            <ul>
              <li>Link Title</li>
              <li>Link Avatar</li>
              <li>Link Author Name</li>
            </ul>
          </li>
          <li>Article Author Details
            <ul>
              <li>Author Name</li>
              <li>Author Avatar</li>
            </ul>
          </li>
          <li>Article Details
            <ul>
              <li>Published Date</li>
              <li>Modified Date</li>
            </ul>
          </li>
          <li>Share Buttons</li>
        </ul>
      </li>
    </ul>

    <p>So all in all, way more complicated than the typical:</p>
    <ul>
      <li>Article
        <ul>
          <li>Article Title</li>
          <li>Article Content</li>
        </ul>
      </li>
    </ul>

    <p>So say for example, where should all the stuff in the complicated (real-world) example go? Should the avatar go in the header, the article, or the footer? Or maybe even a details element? Should the navigation links to other articles be like: nav &gt; ul &gt; li &gt; article &gt; header &gt; a &gt; h1 With the a containing the link, and the h1 containing the article header? Should the post details (despite we want them display perhaps underneath the title, and before the content) be in a details element? And should that be within the header element or be below the header element? Should they use for example:</p>

<pre><code>&lt;dl&gt;
  &lt;dt class="published"&gt;Published At:&lt;/dt&gt;
  &lt;dd class="published"&gt;...&lt;/dd&gt;
&lt;/dl&gt;</code></pre>

    <p>or:</p>

<pre><code>&lt;ul&gt;
  &lt;li class="published"&gt;
    &lt;label&gt;Published At:&lt;/label&gt;
    &lt;span&gt;...&lt;/span&gt;
  &lt;/li&gt;
&lt;/ul&gt;</code></pre>

    <p>or something else? The second example seems to remove the duplication of the css class, but seems to add more complications though. Should those tag and article links in nav elements be inside the header? Or footer? Or just article? How many footers and headers can be in article?</p>

    <p>I&#8217;m soo confused. Any help would be greatly appreciated? Perhaps the best help out there would be a detailed HTML5 example of the real-world article structure I posted above.</p>
  </blockquote>
  <p>OK now, take a deeeep breath and relax. There, feeling a little better? <img src='http://html5doctor.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

  <p>That&#8217;s a mammoth e-mail, so here are some basics to get you started:</p>

  <ul>
    <li>Start with a basic page before attempting something complex — don&#8217;t jump in the deep end.</li>
    <li>Look at websites in <a href="http://html5gallery.com"><abbr>HTML</abbr>5 Gallery</a> and check their code.</li>
    <li>Look at the code for this site. Granted, it&#8217;s not perfect, but it&#8217;s pretty good, and we have a lot of the content you list.</li>
    <li>Use the most appropriate element for each piece of content, even if it&#8217;s not one of the new ones. (Hopefully it ends up being what you used before.) Perhaps <a href="http://html5doctor.com/happy-1st-birthday-us/">our handy flowchart</a> might help for that.</li>
  </ul>

  <p>Some more specific answers:</p>
  
  <p><q>&#8220;Should the navigation links to other articles be like: nav &gt; ul &gt; li &gt; article &gt; header &gt; a &gt; h1 With the a containing the link, and the h1 containing the article header?&#8221;</q> The title of an article is not the same as an article, so it&#8217;d be wrong to use <code>&lt;article&gt;</code> or <code>&lt;header&gt;</code> here. I assume you didn’t use <code>&lt;h1&gt;</code> in <a href="http://html5doctor.com/nav-element/">navigation</a> lists before, right?</p>

  <p><q>&#8220;Should the post details (despite we want them display perhaps underneath the title, and before the content) be in a details element?&#8221;</q> Possibly, if you wanted that interaction, but likely not as you probably want them visible all the time. See what the <a href="http://dev.w3.org/html5/markup/details">spec says about <code>&lt;details&gt;</code></a>. Decide on the semantics of each piece of content first. Worry about styling later.</p>

  <p><q>&#8220;And should that be within the header element or be below the header element?&#8221;</q> <a href="http://html5doctor.com/the-header-element/">Header</a> or <a href="http://html5doctor.com/the-footer-element/">footer</a> seem like good places to put them. <code>&lt;label&gt;</code> is a caption for a form control, not an element to use whenever you need to label something.</p>

  <p>I recommend you start with your <abbr>HTML</abbr>4 or <abbr>XHTML</abbr>1 knowledge and build on it. <abbr>HTML</abbr>5 is an evolution, not a revolution. In fact, I’d recommend you start out making a site in <abbr>HTML</abbr>4 with the <abbr>HTML</abbr>5 doctype (and validate it as <abbr>HTML</abbr>5), then change bits over time as you read each article on <a href="http://html5doctor.com"><abbr>HTML</abbr>5 Doctor</a> and learn more <img src='http://html5doctor.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

  <p>peace &#8211; Oli</p>
</section>

<section>
	<h2>Got a question for us?</h2>
	<p>That wraps up this round of questions. If you&#8217;ve got a query about the <abbr>HTML</abbr>5 spec or how to implement it, you can <a href="http://html5doctor.com/ask-the-doctor/">get in touch</a> with us and we&#8217;ll do our best to help.</p>
</section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/your-questions-15/" rel="bookmark" class="crp_title">Your Questions #15</a></li><li><a href="http://html5doctor.com/your-questions-16/" rel="bookmark" class="crp_title">Your Questions #16</a></li><li><a href="http://html5doctor.com/your-questions-answered-8/" rel="bookmark" class="crp_title">Your Questions Answered #8</a></li><li><a href="http://html5doctor.com/your-questions-answered-4/" rel="bookmark" class="crp_title">Your Questions Answered #4</a></li><li><a href="http://html5doctor.com/your-questions-answered-11/" rel="bookmark" class="crp_title">Your Questions Answered #11</a></li></ul></div><p><a href="http://html5doctor.com/your-questions-14/" rel="bookmark">Your Questions #14</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on November 26, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-14/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Your Questions #13</title>
		<link>http://html5doctor.com/your-questions-13/</link>
		<comments>http://html5doctor.com/your-questions-13/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 14:15:52 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[custom tags]]></category>
		<category><![CDATA[h1]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[hgroup]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2382</guid>
		<description><![CDATA[The clinic is getting busy with more <abbr>HTML</abbr>5 ailments. This week, we'll cover server-side validation, immutable images with <code>&#60;canvas&#62;</code>, retrieving drawn objects from a <code>&#60;canvas&#62;</code>, creating custom tags, the <code>role</code> attribute, and the effects of <code>&#60;hgroup&#62;</code> on <abbr>SEO</abbr>.]]></description>
			<content:encoded><![CDATA[<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Doctor treating a patient illustration" class="alignright size-full wp-image-424" /> The clinic is getting busy with more <abbr>HTML</abbr>5 ailments. This week, we&#8217;ll cover server-side validation, immutable images with <code>&lt;canvas&gt;</code>, retrieving drawn objects from a <code>&lt;canvas&gt;</code>, creating custom tags, the <code>role</code> attribute, and the effects of <code>&lt;hgroup&gt;</code> on <abbr>SEO</abbr>.</p>
<section>
<h2>Server-side validation</h2>
<p>Brian asked:</p>
<blockquote>
<p>We currently use <abbr>PHP</abbr>-Tidy to validate the <abbr>HTML</abbr> mark-up of content regions of our site. Our content regions have images that represent modules in our system that get translated into code for things like processing video, forms, etc. I&#8217;ve been making the move to upgrade these modules to use new <abbr>HTML</abbr>5 elements, but I&#8217;m finding that Tidy is stripping out these elements and I&#8217;m doing a lot of dancing around these issues right now. Are you aware of any server-side processing scripts that have been updated to work with <abbr>HTML</abbr>5 and perhaps with <abbr>ARIA</abbr> support as well?</p>
</blockquote>
<p>The current contender is <a href="http://code.google.com/p/html5lib/">html5lib</a>. The <abbr>PHP</abbr> version is v0.1, so <abbr title="Your Mileage May Vary">YMMV</abbr>.</p>
<p>It seems that <a href="http://lists.w3.org/Archives/Public/html-tidy/2010JanMar/0005.html"><abbr>HTML</abbr>5 support won’t be coming to Tidy anytime soon</a>.</p>
<p>Good luck! Peace &#8211; Oli</p>
</section>
<section>
<h2>Immutable image with <code>&lt;canvas&gt;</code></h2>
<p>Mike asked:</p>
<blockquote>
<p>We do have a medical app and we want to use <code>&lt;canvas&gt;</code> to let docs draw over a still picture.  The only thing I cannot do is keep the picture unchanged when they use an &#8220;eraser&#8221; (basically a white pen). I haven&#8217;t found any example on the web so may be it&#8217;s impossible. It seems that the background image either part of the <code>canvas</code> of a <code>div</code> containing the canvas becomes part of the canvas itself. If it&#8217;s possible what&#8217;s the secret? Thanks</p>
</blockquote>
<p>This is possible in a variety of ways. Here&#8217;s a quick demonstration of <a href="http://jsbin.com/icumi3/2">one of the solutions</a>. Open the demo up in Firefox 3.6 or later, drop an image in the box, draw over it, and click the &#8220;Drawn image as PNG&#8221; button to retrieve what you drew (without the background image).</p>
<p>Here&#8217;s what&#8217;s happening: the canvas is sitting inside of a <code>&lt;div&gt;</code> containing my still image, but I&#8217;m drawing on the nested <code>&lt;canvas&gt;</code> (I think you had it the other way around, which was causing your problems).</p>
<p>Hope that helps, Remy</p>
</section>
<section>
<h2>Retrieving objects from <code>&lt;canvas&gt;</code></h2>
<p>DJ asked:</p>
<blockquote>
<p>I wanted to know if there is any way in which the drawn objects say rectangle, circle, line, &hellip; within canvas can be identified based on the selection at later point in time (after they are drawn).</p>
<p>If there are no direct <abbr>API</abbr>s how could we achieve it. Do we have to store the co-ordinates of each of the created object within and do the object identification based on mouse cursor? Thanks</p>
</blockquote>
<p>Unfortunately, there&#8217;s no way to retrieve these objects unless you write your own system to handle it. There&#8217;s no native support for this in <code>&lt;canvas&gt;</code>.</p>
<p>It sounds like you actually need to use <abbr>SVG</abbr>, which will allow to you to hook event listeners and query the <abbr>DOM</abbr> tree that&#8217;s created. If you need some convincing that <abbr>SVG</abbr> is the right tool for the job, have a look at the <a href="http://raphaeljs.com/">Raphaël JavaScript Library</a>. It uses <abbr>SVG</abbr> exclusively and is able to create some very impressive drawings and animations.</p>
<p>Cheers, Remy</p>
</section>
<section>
<h2>Custom tags</h2>
<p>Mike asked:</p>
<blockquote>
<p>So by using some JavaScript I can insert unfamiliar tags into <abbr>IE</abbr>, and using <abbr>CSS</abbr> I can format them. My question is why stop with <abbr>HTML</abbr>5 tags like section and nav? What are the pros and cons of custom tags like <code>&lt;content&gt;</code>, <code>&lt;story&gt;</code>, <code>&lt;comment&gt;</code>, <code>&lt;blog&gt;</code> or even <code>&lt;mike&gt;</code>, <code>&lt;was&gt;</code>, <code>&lt;here&gt;</code>?</p>
</blockquote>
<p>Custom elements go against having a standard like <abbr>HTML</abbr>5. Standards map out the set of elements, attributes, and <abbr>API</abbr>s that the browsers need to implement so web developers can use them, and they provide those developers with a common approach to marking up a web page.</p>
<p>If custom elements were allowed, we would have an infinite number of ways to mark up content, many of which would share a common goal but require different implementations. As an example, here is a number of different elements I can dream up for some primary content: <code>&lt;article&gt;</code>, <code>&lt;blog&gt;</code>, <code>&lt;entry&gt;</code>, <code>&lt;post&gt;</code>, <code>&lt;page&gt;</code>, <code>&lt;main&gt;</code>, <code>&lt;primary&gt;</code>, <code>&lt;content&gt;</code>, <code>&lt;document&gt;</code>, <code>&lt;doc&gt;</code>, <code>&lt;blogpost&gt;</code>, <code>&lt;publication&gt;</code>, <code>&lt;thenameofthearticlewithnospacesorpunctuation&gt;</code>, <code>&lt;item&gt;</code>, <code>&lt;block&gt;</code>, <code>&lt;blob&gt;</code>, <code>&lt;text&gt;</code>, <code>&lt;txt&gt;</code>, and <code>&lt;paper&gt;</code>. Many of them are bad ideas, but hopefully you see my point. This doesn&#8217;t even account for the more predictable <code>&lt;contentone&gt;</code>, <code>&lt;contenttwo&gt;</code>, <code>&lt;articlefifty&gt;</code> that would likely also be used.</p>
<p>This sort of markup would make <abbr>HTML</abbr> a nightmare to maintain. A developer coming into an existing site would have to learn which elements have been used and what their purpose is. And it&#8217;s not just painful for developers. Browser vendors would have to find ways to parse these elements and define how they should be used. Is this element supposed to be block-level? Is it interactive? Should it impact the document outline? And what about search engines? How do they know that <code>&lt;myobscureelement&gt;</code> defines the most important content on the page, the content that should really be indexed?</p>
<p>Standards narrow the possibilities and ensure developers, browsers, and machines (search engines and the like) are all speaking the same language. Many people spend a great deal of time debating the specification, trying to reach consensus on which proposals should be standardized and how they should be implemented.</p>
<p>So stick to the standards! They exist for everyone&#8217;s benefit. As browsers continue to implement the specification correctly (even <abbr>IE</abbr> is catching up), our jobs will be made easier and we can spend more time creating really cool things <img src='http://html5doctor.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>John Alsopp&#8217;s fantastic article <a href="http://www.alistapart.com/articles/semanticsinhtml5">Semantics in <abbr>HTML</abbr>5</a> goes into more detail about this issue. You can also see where some of the element names came from by looking at the work Hixie did researching <a href="http://code.google.com/webstats/2005-12/classes.html">class names in Google&#8217;s index</a>.</p>
<p>Regards, Mike</p>
</section>
<section>
<h2>The <code>role</code> attribute, SEO, and <code>&lt;hgroup&gt;</code></h2>
<p>Robson asked:</p>
<blockquote>
<p>What about the role attribute? Was it dropped from specification? What will be the &#8220;role&#8221; of the role attribute in <abbr>HTML</abbr>5?</p>
<p>Today, just the home page should have the name of the site into a H1 element. On others pages, the H1 should be used to the title of the articles. How do search engines interpret the HGROUP and multiples HEADER and H1 elements today? How to implement the HGROUP and the HEADER today without impact the SEO? Thanks, guys!</p>
</blockquote>
<p>To answer your first three questions, <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/content-models.html#annotations-for-assistive-technology-products-(aria)"><code>role</code> is in</a>. You can use it belt-and-suspenders style until assistive technology catches up with <abbr>HTML</abbr>5. Just be careful: “<q>Authors may use the <abbr>ARIA</abbr> role and aria-* attributes on <abbr>HTML</abbr> elements, in accordance with the requirements described in the <abbr>ARIA</abbr> specifications, except where these conflict with the strong native semantics described below</q>”.</p>
<p>For the second part of your question, that&#8217;s not true. You can use more than one <code>&lt;h1&gt;</code> in <abbr>HTML</abbr> 4/<abbr>XHTML</abbr> 1. It&#8217;s not advised to make every heading <code>&lt;h1&gt;</code> in <abbr>HTML</abbr> 4/<abbr>XHTML</abbr> 1 (because historically some people did that to spam), but it may be appropriate in some cases — e.g., site name and page title. Using two <code>&lt;h1&gt;</code>&#8216;s on a single page has no effect on <abbr>SEO</abbr>.</p>
<p>With regard to <code>&lt;hgroup&gt;</code> and <code>&lt;header&gt;</code>, you’re asking the wrong question. Search engines care about high-quality, relevant content. Search engines penalise spamming, but writing markup according to the specification is not spamming. The <abbr>HTML</abbr>5 editor works at Google, so they’re well aware of the spec. html5doctor.com <em>has</em> implemented <code>&lt;hgroup&gt;</code> and <code>&lt;header&gt;</code>, and it hasn&#8217;t hurt our search engine rankings any <img src='http://html5doctor.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>For more, see our articles on <a href="http://html5doctor.com/the-header-element/">the header element</a> and <a href="http://html5doctor.com/the-hgroup-element/">the hgroup element</a>.</p>
<p>You probably don’t want to use <code>&lt;h1&gt;</code> everywhere anyhow, as <abbr>CSS</abbr> selectors are not that smart. <em>If</em> you wrap every <code>&lt;h1&gt;</code>-<code>&lt;h6&gt;</code> in a sectioning element (<code>&lt;section&gt;</code>, <code>&lt;article&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;aside&gt;</code>), you don’t have to worry about keeping a logical order for your headings. Doing this means you don’t need to overwrite <abbr>CSS</abbr> as much. The old style, however, with the requirement to keep a logical order for your headings, still works.</p>
<p>Again, you&#8217;re concerned with the wrong thing. Good SEO = good content. Worrying about placement or what search engines think is a waste of time — worry about good content.</p>
<p>Peace &#8211; Oli</p>
</section>
<section>
<h2>Got a question for us?</h2>
<p>That wraps up this round of questions. If you&#8217;ve got a query about the <abbr>HTML</abbr>5 spec or how to implement it, you can <a href="http://html5doctor.com/ask-the-doctor/">get in touch</a> with us and we&#8217;ll do our best to help.</p>
</section>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/your-questions-answered-11/" rel="bookmark" class="crp_title">Your Questions Answered #11</a></li>
<li><a href="http://html5doctor.com/your-questions-16/" rel="bookmark" class="crp_title">Your Questions #16</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-7/" rel="bookmark" class="crp_title">Your Questions Answered #7</a></li>
<li><a href="http://html5doctor.com/your-questions-5/" rel="bookmark" class="crp_title">Your Questions Answered #5</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/your-questions-13/" rel="bookmark">Your Questions #13</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on September 28, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-13/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>.net Awards Nomination</title>
		<link>http://html5doctor.com/net-awards-nomination/</link>
		<comments>http://html5doctor.com/net-awards-nomination/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 11:19:26 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[awards]]></category>
		<category><![CDATA[netmag]]></category>
		<category><![CDATA[practical web design]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2470</guid>
		<description><![CDATA[<p>As you may or may not be aware, .net, the world's best-selling magazine for web builders, has opened voting for its annual .net Awards – a celebration of the very best in web design and development. We're proud to announce that not only has HTML5 Doctor been nominated in the blog of the year category but messers Lawson &#38; Sharp have also been nominated in the standards champion category.</p>]]></description>
			<content:encoded><![CDATA[<p>The world&#8217;s best-selling magazine for web builders, <a href="http://www.netmag.co.uk/">.net</a> (or &#8220;Practical Web Design&#8221; outside the UK) has opened voting for its annual .net Awards – a celebration of the very best in web design and development. We&#8217;re proud to announce that not only has HTML5 Doctor been nominated in the blog of the year category but Messrs. <a href="http://html5doctor.com/author/brucel/">Lawson</a> &amp; <a href="http://html5doctor.com/author/remys/">Sharp</a> have also been nominated in the standards champion category.</p>

<section>
  <h2>The .net Awards</h2>
  
  <p><img src="http://html5doctor.com/wp-content/uploads/2010/08/net-awards-logo.jpg" alt=".net awards logo 2010" class="alignright" /> Held annually since 1998, the long-running .net Awards mix public opinion with those of a leading panel of 100 industry experts, including the likes of Jeffrey Zeldman, Paul Boag and Molly Holzschlag, who deliberate on the final shortlist. (Disclosure: I am a judge for this years awards, but will abstain from voting in the two categories that HTML5 Doctor is represented.)</p> 

  <p>Winners of the prestigious .net Awards 2010 are announced on Thursday, 18th November at a special event in London.</p>
</p>
</section>

<section>
  <h2>Your vote counts</h2>
  <p>Without wanting to go all Obama on you, <strong>your vote counts</strong>. To see all the categories and nominees please <a href="http://www.thenetawards.com/">visit the site and vote</a>. If that vote happens to be for HTML5 Doctor as blog of the year or HTML5 surgeons <a href="http://twitter.com/brucel">Bruce</a> or <a href="http://twitter.com/rem">Remy</a> as your standards champion then we&#8217;d all be super-grateful (and one of Remy&#8217;s side projects <a href="http://snapbird.org">Snap Bird</a>, for searching twitter better, is up for best API use too).</p><p> For us  to be nominated alongside some well established, fantastically popular blogs is a great achievement and one that we&#8217;re really proud of. Especially when you consider we&#8217;ve only been going for <a href="http://html5doctor.com/happy-1st-birthday-us/">a little over a year</a>. Anything more would be a bonus and being nominated has really invigorated us to kick on and keep producing compelling content for you guys.</p>
  
  <p>For more information and the chance to vote, visit <a href="http://www.thenetawards.com">the .net awards site</a>.</p>
</section><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/get-your-html5-prescription-filled-at-media/" rel="bookmark" class="crp_title">Get your HTML5 prescription filled at @media</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/html5-simplequiz-6-zeldmans-fat-footer/" rel="bookmark" class="crp_title">HTML5 Simplequiz 6: Zeldman&#8217;s fat footer</a></li><li><a href="http://html5doctor.com/two-cheers-for-the-w3cs-html5-logo/" rel="bookmark" class="crp_title">Two cheers for the W3C&#8217;s HTML5 logo</a></li></ul></div><p><a href="http://html5doctor.com/net-awards-nomination/" rel="bookmark">.net Awards Nomination</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on August 26, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/net-awards-nomination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

