<?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; Browser Compatibility</title>
	<atom:link href="http://html5doctor.com/category/browser-compatibility/feed/" rel="self" type="application/rss+xml" />
	<link>http://html5doctor.com</link>
	<description>helping you implement HTML5 today</description>
	<lastBuildDate>Wed, 16 May 2012 11:31:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Using Modernizr to detect HTML5 features and provide fallbacks</title>
		<link>http://html5doctor.com/using-modernizr-to-detect-html5-features-and-provide-fallbacks/</link>
		<comments>http://html5doctor.com/using-modernizr-to-detect-html5-features-and-provide-fallbacks/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 13:30:04 +0000</pubDate>
		<dc:creator>Tom Leadbetter</dc:creator>
				<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[modernizr]]></category>
		<category><![CDATA[yepnope]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=4371</guid>
		<description><![CDATA[<p>Modernizr is a JavaScript library that detects which HTML5 and CSS3 features your visitor's browser supports. In detecting feature support, it allows developers to test for some of the new technologies and then provide fallbacks for browsers that do not support them. This is called <dfn>feature detection</dfn> and is much more efficient than browser sniffing. In this article we'll look at how to use Modernizr for feature detection.</p>]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;"><img src="http://html5doctor.com/wp-content/uploads/2012/02/modernizr-logo.jpg" alt="Modernizr logo" width="296" height="87" /></p>
<p><a href="http://www.modernizr.com/">Modernizr</a> is a JavaScript library that detects which HTML5 and CSS3 features your visitor&#8217;s browser supports. In detecting feature support, it allows developers to test for some of the new technologies and then provide fallbacks for browsers that do not support them. This is called <dfn>feature detection</dfn> and is much more efficient than browser sniffing.</p>
<div class="callout">
<p>Modernizr is very useful for detecting CSS3 support, but this article will focus on HTML5. The principles are essentially the same, though.</p>
</div>
<p>It&#8217;s important to note that Modernizr doesn&#8217;t &#8220;fill in the gaps&#8221; (i.e., <a href="https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills" title="HTML5 Cross-browser Polyfills on GitHub">polyfill</a>) for you. It only detects whether something is supported. But you can use Modernizr as part of the polyfilling process.</p>
<div class="callout highlight-block">
<p>Versions of IE8 and below do not recognise new-in-HTML5 elements by default, so you have to fix this with some JavaScript. You could possibly create each of these yourself with the below code, or you might use the <a href="http://code.google.com/p/html5shiv/">HTML5 Shiv</a> by <a href="http://twitter.com/rem" title="Remy Sharp on Twitter">@rem</a>, which includes all the new elements.</p>
<p>Modernizr does all this for you, so you don&#8217;t need include the Shiv.</p>
</div>
<section id="getting-started">
<h2>Getting Started <a href="#getting-started" class="permalink">#</a></h2>
<p>First, you need an HTML document:</p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html class="no-js" lang="en"&gt;
&lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Hello Modernizr&lt;/title&gt;
  &lt;script src="modernizr.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>You can see in the code above that you need a <code>modernizr.js</code> file. You have to <a href="http://www.modernizr.com/download/">build and download</a> this yourself by choosing the features you want to detect. Do this by choosing the &#8216;Production&#8217; option in Figure 1 and then ticking the necessary options in Figure 2. This helps keep the file size down by not detecting everything Modernizr is capable of. There is a <a href="http://www.modernizr.com/downloads/modernizr-2.0.6.js">development version</a> (see Figure 1) that you can link to whilst developing your site, but before you put the site live, you should build the production file you need.</p>
<figure>
    <img src="http://html5doctor.com/wp-content/uploads/2012/02/download-modernizr.jpg" alt="Modernizr download options" width="522" height="202" /></p>
<figcaption>Figure 1: Modernizr download options</figcaption>
</figure>
<figure>
    <img src="http://html5doctor.com/wp-content/uploads/2012/02/download-modernizr-2.jpg" alt="Modernizr build options" width="880" height="863" /></p>
<figcaption>Figure 2: Modernizr configuration &amp; build options</figcaption>
</figure>
<p>Also notice the second line of the HTML above: there is a <code>no-js</code> class on the <code>&lt;html&gt;</code> element. Modernizr first removes this and replaces it with a <code>js</code> class, which could be useful in your CSS. Along with the <code>js</code> class, it adds classes for all the features the browser supports <em>and</em> for the features it does not support, pre-fixing those with <code>no-</code>.</p>
<p>Here are two examples, one from Chrome 16 and one from IE9:</p>
<figure>
<pre><code>&lt;html class="js flexbox canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths"&gt;</code></pre>
<figcaption>Figure 3: Modernizr&#8217;s feature detection in Chrome 16</figcaption>
</figure>
<figure>
<pre><code>&lt;html class="js <mark>no-flexbox</mark> canvas canvastext <mark>no-webgl</mark> no-touch geolocation postmessage <mark>no-websqldatabase</mark> <mark>no-indexeddb</mark> hashchange <mark>no-history</mark> draganddrop <mark>no-websockets</mark> rgba hsla multiplebgs backgroundsize <mark>no-borderimage</mark> borderradius boxshadow <mark>no-textshadow</mark> opacity <mark>no-cssanimations</mark> <mark>no-csscolumns</mark> <mark>no-cssgradients</mark> <mark>no-cssreflections</mark> csstransforms <mark>no-csstransforms3d</mark> <mark>no-csstransitions</mark> fontface generatedcontent video audio localstorage sessionstorage <mark>no-webworkers</mark> <mark>no-applicationcache</mark> svg inlinesvg smil svgclippaths"&gt;</code></pre>
<figcaption>Figure 4: Modernizr&#8217;s feature detection in IE9</figcaption>
</figure>
</section>
<section id="detection">
<h2>Do Some Detecting <a href="#detection" class="permalink">#</a></h2>
<p>Modernizr creates a global <code>Modernizr</code> JavaScript object, which allows us to query <a href="http://www.modernizr.com/docs/#features-html5" title="Full list of Modernizr's HTML5 feature detection">different properties</a> of that object to perform feature detection by calling <code>Modernizr.&lt;featurename&gt;</code>. So to test for <code>canvas</code> support, you would write the following:</p>
<pre><code>&lt;script&gt;
  <strong>if (Modernizr.canvas) {</strong>
    alert("This browser supports HTML5 canvas!");
  <strong>}</strong>
&lt;/script&gt;</code></pre>
<p>So <a href="/demos/modernizr/canvas-yes.htm" title="Live Example #1">try this page</a> in a modern browser and there will be a nice message for you.</p>
<p>Because you&#8217;re all good developers and write unobtrusive, progressive JavaScript so that everyone can use your site, you also want to check if canvas is <em>not</em> supported. You have a couple of options here. You could use the above <code>if</code> statement along with an <code>else</code> statement, <a href="/demos/modernizr/canvas-both.htm" title="Live Example #2">like so</a>:</p>
<pre><code>&lt;script&gt;
  if (Modernizr.canvas) {
    alert("This browser supports HTML5 canvas!");
  } <strong>else {
    alert("no canvas :(");
  }</strong>
&lt;/script&gt;</code></pre>
<p>Or if you want to test purely for no canvas support, you can negate the condition <a href="/demos/modernizr/canvas-not.htm" title="Live Example #3">like this</a>:</p>
<pre><code>&lt;script&gt;
  if (<strong>!Modernizr.canvas</strong>) {
    alert("No canvas here");
  }
&lt;/script&gt;</code></pre>
</section>
<section id="yep-nope">
<h2>Feature Detection and Polyfilling with YepNope <a href="#yep-nope" class="permalink">#</a></h2>
<p>In the examples above, you&#8217;ve seen the simplest way to detect a browser feature. What if you wanted to detect a feature and use a polyfill to make the browser perform better? You can do this with <a href="http://yepnopejs.com">YepNope</a>.</p>
<p>YepNope is a conditional loader, which means it will only load the scripts that are needed by the browser. And it&#8217;s built into Modernizr, so you don&#8217;t have to worry about downloading and linking to another JavaScript file.</p>
<p>So how do you use it?</p>
<p>Using canvas as an example again, you’ll generally want a fallback for non-supporting IE8 and below. The usual way of doing this would be to link to a JavaScript polyfill, such as <a href="http://flashcanvas.net">FlashCanvas</a> in your HTML:</p>
<pre><code>&lt;script src="http://flashcanvas.net/bin/flashcanvas.js"&gt;&lt;/script&gt;</code></pre>
<p>The problem with this approach is that all browsers will download this script. That&#8217;s unnecessary and should be avoided where possible. You could arguably wrap the <code>&lt;script&gt;</code> element in conditional comments, but if you can keep the files out of the markup altogether, then you should. You can do this using <code>Modernizr.load()</code>. Modernizr has YepNope built into it, so you can easily test for a feature and then supply a polyfill.</p>
<p>So let&#8217;s take a look.</p>
<div class="callout">
<p>You should note that <code>.load()</code> is not included in the development file by default. You need to include it and build it yourself.</p>
</p></div>
<p>The basic use of the <code>.load()</code> function allows you to <code>test</code> for a feature and ask whether it&#8217;s true (<code>yep</code>) or false (<code>nope</code>). In this example, Modernizr tests for canvas support, and if the feature doesn&#8217;t exist, then it loads FlashCanvas:</p>
<pre><code>Modernizr.load({
  test: Modernizr.canvas,
  nope: 'http://flashcanvas.net/bin/flashcanvas.js'
});</code></pre>
<p>So open up IE8, take a look at the network tab (Figure 5) in the developer tools. With the above code, you&#8217;ll see that it downloaded and initialised <code>flashcanvas.js</code>. Pretty nifty, yes?</p>
<figure class="wider">
    <img src="http://html5doctor.com/wp-content/uploads/2012/02/ie8-network.jpg" alt="" width="733" height="194" /></p>
<figcaption>Figure 5: FlashCanvas resources loaded in IE8</figcaption>
</figure>
<p>Here&#8217;s a more practical example that detects the support of <code>&lt;input type="date"&gt;</code>. If it isn&#8217;t supported, it loads in <strong>two</strong> jQuery files and a CSS file to generate a styled date picker:</p>
<pre><code>&lt;script src="modernizr.js"&gt;&lt;/script&gt;
&lt;script&gt;Modernizr.load({
  test: Modernizr.inputtypes.date,
  nope: ['http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js', 'jquery-ui.css'],
  complete: function () {
    $('input[type=date]').datepicker({
      dateFormat: 'yy-mm-dd'
    });
  }
});
&lt;/script&gt;</code></pre>
<p>This test looks for <code>&lt;input type="date"&gt;</code> support. When it fails, it loads in the two external jQuery JavaScript files and a local CSS file. (Our tests suggest that the CSS file needs to be local.) Once it&#8217;s done that (i.e., on <code>complete</code>), it then calls the plugin for each <code>&lt;input type="date"&gt;</code> in the DOM. In most browsers, the jQuery will be loaded (Figure 6), but in Opera, the files aren&#8217;t loaded because it has a native calendar control (Figure 7):</p>
<figure>
    <img src="http://html5doctor.com/wp-content/uploads/2012/02/calendar-firefox.png" alt="jQuery date picker widget" width="430" height="276" /></p>
<figcaption>Figure 6: jQuery date picker widget in Firefox</figcaption>
</figure>
<figure>
    <img src="http://html5doctor.com/wp-content/uploads/2012/02/calendar-opera.png" alt="Opera date picker widget" width="361" height="276" /></p>
<figcaption>Figure 7: Native date picker widget in Opera</figcaption>
</figure>
<p>The two figures below show the difference in which resources the browsers downloads:</p>
<figure>
    <img src="http://html5doctor.com/wp-content/uploads/2012/02/resources-firefox.png" alt="Resources loaded in Firefox" width="253" height="194" /></p>
<figcaption>Figure 8: Date picker resources loaded in Firefox</figcaption>
</figure>
<figure>
    <img src="http://html5doctor.com/wp-content/uploads/2012/02/resources-opera.png" alt="Resources loaded in Opera" width="170" height="70" /></p>
<figcaption>Figure 9: Date picker resources loaded in Opera</figcaption>
</figure>
<p>Notice how the two jQuery JavaScript files are loaded twice. That&#8217;s a <a href="http://yepnopejs.com/#twice">YepNope behaviour</a>, first loading the resource and then executing it. So don&#8217;t worry, that&#8217;s normal.</p>
<p>You can do much more with YepNope. Here&#8217;s <a href="http://yepnopejs.com/#testObject">an example taken from the YepNope web site</a> of all the possible properties, all of which are optional:</p>
<pre class="tallCode"><code>yepnope([{
    test : <span class="optional">/* boolean<span class="comment">(ish)</span> - Something truthy that you want to test */</span>,
    yep : <span class="optional">/* array <span class="comment">(of strings)</span> | string - The things to load if <span class="keyword">test</span> is <span class="keyword">true</span> */</span>,
    nope : <span class="optional">/* array <span class="comment">(of strings)</span> | string - The things to load if <span class="keyword">test</span> is <span class="keyword">false</span> */</span>,
    both : <span class="optional">/* array <span class="comment">(of strings)</span> | string - Load everytime (sugar) */</span>,
    load : <span class="optional">/* array <span class="comment">(of strings)</span> | string - Load everytime (sugar) */</span>,
    callback : <span class="optional">/* function ( testResult, key ) | object { key : fn } */</span>,
    complete : <span class="optional">/* function */</span> }, /* ... */ ]);</code></pre>
</section>
<section id="conclusion">
<h2>Conclusion <a href="#conclusion" class="permalink">#</a></h2>
<p>Modernizr is a powerful feature detection library. It allows you to check whether a browser supports various features and, depending on what you want to achieve, lets you use a polyfill. This article looked at how to generate a Modernizr JavaScript file and examined two different ways of using Modernizr: directly using the Modernizr object (<code>Modernizr.&lt;featurename&gt;</code>) and then using the built-in YepNope.</p>
<p>So, what do you think? Let us know in the comments below!</p>
</section>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/ol-element-attributes/" rel="bookmark" class="crp_title">The <code>ol</code> Element and Related Attributes: <code>type</code>, <code>start</code>, <code>value</code>, and <code>reversed</code></a></li>
<li><a href="http://html5doctor.com/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/the-details-and-summary-elements/" rel="bookmark" class="crp_title">The details and summary elements</a></li>
<li><a href="http://html5doctor.com/drag-and-drop-to-server/" rel="bookmark" class="crp_title">Drag and Drop and Automatically Send to the Server</a></li>
<li><a href="http://html5doctor.com/storing-data-the-simple-html5-way-and-a-few-tricks-you-might-not-have-known/" rel="bookmark" class="crp_title">Storing Data the Simple HTML5 Way (and a few tricks you might not have known)</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/using-modernizr-to-detect-html5-features-and-provide-fallbacks/" rel="bookmark">Using Modernizr to detect HTML5 features and provide fallbacks</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on March 27, 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/using-modernizr-to-detect-html5-features-and-provide-fallbacks/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>YouTube and Vimeo support HTML5 Video</title>
		<link>http://html5doctor.com/youtube-and-vimeo-support-html5-video/</link>
		<comments>http://html5doctor.com/youtube-and-vimeo-support-html5-video/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 16:08:28 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[vimeo]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1315</guid>
		<description><![CDATA[Unless you've been hiding under an <abbr>XHTML</abbr>2 shaped rock for the past week or so you'll know that both YouTube and Vimeo have announced plans to support the <abbr>HTML</abbr>5 video element.]]></description>
			<content:encoded><![CDATA[<p>Unless you&#8217;ve been hiding under an <abbr>XHTML</abbr>2 shaped rock for the past week or so, you&#8217;ll know that both YouTube and Vimeo have announced plans to support the <abbr>HTML</abbr>5 video element. Two <a href="http://youtube-global.blogspot.com/2010/01/introducing-youtube-html5-supported.html" title="Introducing YouTube HTML5 Supported Videos">blog</a> <a href="http://www.vimeo.com/blog:268" title="Try our new HTML5 player! on Vimeo Staff Blog">posts</a> published last week announced that the two major players in online video are experimenting with the <abbr>HTML</abbr>5 <a href="http://html5doctor.com/the-video-element/"><code>&lt;video&gt;</code> element</a>.</p>
<p><img src="http://html5doctor.com/wp-content/uploads/2010/01/yt-vimeo.jpg" alt="YouTube and Vimeo Logos" /></p>
<h2>Will it work cross browser?</h2>
<p>The videos will work natively in Safari and Chrome (well, YouTube would certainly have to, wouldn&#8217;t it?). They&#8217;ll also work in <abbr>IE</abbr> if you have <a href="http://code.google.com/chrome/chromeframe/">ChromeFrame</a> installed (which we all know is cheating). If you&#8217;re using a browser that doesn&#8217;t support <abbr>HTML</abbr>5 video it will default back to the Flash method they currently employ.</p>
<p>Both YouTube and Vimeo use the H.264 codec to encode the videos &mdash; and that&#8217;s where things start to get complicated.</p>
<p>Since no official codec is defined in the spec <ins>because</ins> browser manufacturers have chosen to use different codecs to render <abbr>HTML</abbr>5 video. Opera and Mozilla use the Ogg Theora codec (more on that later), while Apple and Google use H.264. Who knows which side of the fence Microsoft will come down on, but I feel duty bound to mention that the licensors of the H.264 codec include both <a href="http://www.mpegla.com/main/programs/AVC/Pages/Licensors.aspx">Microsoft and Apple</a>.</p>
<h2>The elephant in the room</h2>
<p>There&#8217;s one major problem here: Ogg Theora, the open source video codec supported by both Firefox and Opera, is not supported on either site. It&#8217;s a shame these browsers aren&#8217;t supported, especially since <a href="http://blog.mozilla.com/blog/2010/01/21/firefox-3-6-release/">Firefox 3.6 was released last week</a> and announced support for full-screen video in its native video player.</p>
<h3>Why use Ogg?</h3>
<p>As previously stated, Ogg is an open source codec, meaning it&#8217;s free to use and implement. By contrast, support for native H.264 decoding in a browser costs approximately &#036;5 million per year. (See <a href="http://www.mpegla.com/main/programs/avc/Documents/AVC_TermsSummary.pdf"><cite>summary of AVC/H.264 license terms [PDF]</cite></a>.) It also seems that people creating H.264 content will be liable for royalties starting in 2011.</p>
<p>Far be it from me to get into the ins and outs of the debate over which codec to use, but it seems that open source would be the better way to go. Silivia Pfeiffer (a contractor for Mozilla) <a href="http://blog.gingertech.net/2010/01/25/html5-video-25-h-264-reach-vs-95-ogg-theora-reach/">claims</a> that serving as Ogg Theora will reach more people than serving as H264.</p>
<p>Google, on the other hand, which owns YouTube has said that Theora is not a good enough codec, claiming &#8220;If [youtube] were to switch to theora and maintain even a semblance of the current youtube quality it would take up most available bandwidth across the Internet&#8221;, a claim hotly (and convincingly) contested in Greg Maxwell&#8217;s <a href="http://people.xiph.org/~greg/video/ytcompare/comparison.html">YouTube / Ogg/Theora comparison</a>.</p>
<p>YouTube and Vimeo seem to have discounted Ogg. I&#8217;d love to find out if there are other plans to add support for Firefox and Opera.</p>
<h2>Where does that leave us?</h2>
<p>Ignoring the whole video codec debate, it leaves us in some ways back where we started &mdash; dealing with proprietary software or complicated licensing to create online content rather than using technologies that will allow us to have a truly open web.</p>
<p>With Apple, Google, Mozilla, and Opera not likely to budge on their respective codec choices for <abbr>HTML</abbr>5 video, we can only hope that the developers at market-leading sites like YouTube and Vimeo can implement cross-browser interoperable video just like Kroc Camen&#8217;s <a href="http://camendesign.com/code/video_for_everybody">Video for Everybody</a>. Judging by the aforementioned blog posts, both sites have more plans in the pipeline, which is encouraging.</p>
<p>The codec battles are only beginning, and we&#8217;re waiting to see which direction one big gun will point. Last year, Google (which owns YouTube) <a href="http://googleblog.blogspot.com/2009/08/innovation-in-video-on-web.html">announced</a> that is paying $104million for a company called On2 Technologies, &#8220;a leading creator of high-quality video compression technology&#8221; and which made the original <a href="http://en.wikipedia.org/wiki/VP3#History">VP3 codec</a> which is the basis for Ogg Theora.</p>
<p>What are their plans? To release a &#8220;better&#8221; Theora-like codec into the community? We can only speculate.</p>
<p>Back to today. Although not perfect, these sites&#8217; support for the <code>&lt;video&gt;</code> element is still a massive leap forward for <abbr>HTML</abbr>5. Who knows &mdash; if more large sites continue to adopt <abbr>HTML</abbr>5, maybe it&#8217;ll be ready in 2010 rather than 2022!</p>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<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/the-video-element/" rel="bookmark" class="crp_title">The video element</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-6/" rel="bookmark" class="crp_title">Your Questions Answered #6</a></li>
<li><a href="http://html5doctor.com/native-audio-in-the-browser/" rel="bookmark" class="crp_title">Native Audio in the browser</a></li>
<li><a href="http://html5doctor.com/review-html5-now-dvd/" rel="bookmark" class="crp_title">Review: HTML5 Now (DVD)</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/youtube-and-vimeo-support-html5-video/" rel="bookmark">YouTube and Vimeo support HTML5 Video</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on January 23, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/youtube-and-vimeo-support-html5-video/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Your Questions Answered #4</title>
		<link>http://html5doctor.com/your-questions-answered-4/</link>
		<comments>http://html5doctor.com/your-questions-answered-4/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 08:52:14 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[WAI-ARIA]]></category>
		<category><![CDATA[aria]]></category>
		<category><![CDATA[details]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[xhtml5]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1242</guid>
		<description><![CDATA[Here we go with another post rounding up your HTML5 questions and sharing the answers with the world. We cover a wide range of topics this time, inlcluding ARIA, storage, offline capabilities, and document outlines, so read on to find the answers. We also want to know what areas of HTML5 you&#8217;d like us to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Illustration of a doctor treating a patient" class="alignright size-full wp-image-424" /> Here we go with another post rounding up your <abbr>HTML</abbr>5 questions and sharing the answers with the world. We cover a wide range of topics this time, inlcluding <abbr>ARIA</abbr>, storage, offline capabilities, and document outlines, so read on to find the answers.</p>
<p>We also want to know what areas of <abbr>HTML</abbr>5 you&#8217;d like us to cover in future articles, so <a href="/contact/">let us know</a>!</p>
<h2>Older browsers and <abbr>XHTML</abbr></h2>
<p>Brett Prichard asked:</p>
<blockquote><p>If I were to use one of the new tags in <abbr>HTML</abbr>5, (i.e., <code>&lt;video&gt;</code> or <code>&lt;header&gt;</code>) what would happen when the page is rendered by an older browser?</p>
<p>The other question I have is will there be an <abbr>XHTML</abbr> equivalent? <abbr>XHTML</abbr> 2.0 breaks off compatibility with <abbr>HTML</abbr>s 1-4, but will it be compatible with <abbr>HTML</abbr>5? I prefer to code in <abbr>XHTML</abbr>.</p>
<p>Thank you for reading.</p></blockquote>
<p>To answer your first question: nothing special. The content nested within the element is displayed. (In the case of video, the fallback content is shown.)</p>
<p>Regarding your second question, I wrote about the <a href="/html-5-xml-xhtml-5/"><abbr>XHTML</abbr> serialisation of <abbr>HTML</abbr>5 a while ago</a>.</p>
<p>&mdash; Thanks, Bruce</p>
<h2><abbr>ARIA</abbr></h2>
<p>Joseph Chapman asked:</p>
<blockquote><p>My colleagues and I wish to switch our doctype to the streamlined <code>&lt;!doctype html&gt;</code> and implement several things we learnt from Jeremy Keith last Wednesday, primarily <abbr title="Accessible Rich Internet Applications">ARIA</abbr>. </p>
<p>We know that support is good as long as we add an extra DTD, but we can&#8217;t find the appropriate doctype declaration to stick on the end of <code>...html&gt;</code> Any ideas? We are really keen to kick this off and use a new piece of technology that will help springboard our site to a new level of accessibility. </p>
<p>Any answers appreciated.</p>
<p>Thanks for your help.</p></blockquote>
<p>It&#8217;s okay to add <abbr>ARIA</abbr> to <abbr>HTML</abbr>5 now without using a different doctype. I suggest you give <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/content-models.html#annotations-for-assistive-technology-products-(aria)">this part of the spec</a> a read.</p>
<p>I believe a task force has been created to more closely align <abbr>ARIA</abbr> to <abbr>HTML</abbr>5. We plan to cover <abbr>ARIA</abbr> more in a future post.</p>
<p>Hope this helps</p>
<p>&mdash; Rich </p>
<h2>Attribute Minification</h2>
<p>Nick Leon asked:</p>
<blockquote><p>Hey there HTML5Doctor,</p>
<p>I consider myself a strong <abbr title="Plain Old Semantic HTML">POSH</abbr> developer. One of the requirements for valid <abbr>XHTML</abbr> is that &#8220;attribute minimization&#8221; is not allowed. <abbr>HTML</abbr> permits &#8220;attribute minimization&#8221;, where boolean attributes can have their value omitted entirely, e.g., <code>&lt;option selected&gt;</code>. All XML attributes must have explicit quoted values, so in XML this would be written as <code>&lt;option selected="selected"&gt;</code>.</p>
<p>I was wondering where <abbr>HTML</abbr>5 stands with attribute minimization. I noticed in some of your example code, you provided the minimized form of the attribute, e.g., <code>&lt;audio src="elvis.ogg" controls autobuffer&gt;&lt;/audio&gt;</code>. Is this valid in <abbr>HTML</abbr>5? Would this be the valid version for <abbr>XHTML</abbr>5:</p>
<p><code>&lt;audio src="elvis.ogg" controls="1" autobuffer="0"&gt;&lt;/audio&gt;</code>?</p></blockquote>
<p>Those are both valid <abbr>HTML</abbr>5 structures (however,  controls=&#8221;1&#8243; isn&#8217;t legal; you need to say controls=&#8221;controls&#8221;).</p>
<p>In <abbr>HTML</abbr>5, you can format attributes as you please. In <a href="/html-5-xml-xhtml-5/"><abbr>XHTML</abbr>5 (the <abbr>XML</abbr> serialisation)</a>, you need to obey the <abbr>XML</abbr> rules.</p>
<p>&mdash; Cheers, Bruce</p>
<h2>Offline storage</h2>
<p>Kevin Searle asked:</p>
<blockquote><p>I&#8217;m having a hard time wrapping my head around the offline storage capabilities of the <abbr>HTML</abbr> 5 spec. Can you consider an &#8220;<abbr>HTML</abbr> 5 Offline Storage 101&#8243; article?</p></blockquote>
<p>Just to clarify, do you mean &#8220;storage&#8221; or &#8220;offline&#8221;? They&#8217;re two very different things.</p>
<p>Storage relates to variables, like cookie jars but a lot bigger.</p>
<p>Offline applications are about detecting connectivity and possibly running your app without a connection to the Web.</p>
<p>We (i.e., Remy) will be writing about both of these topics, but it&#8217;s useful to know which is more in demand than the other.</p>
<p>In the meantime, feel free to check out the demos I&#8217;ve written at <a href="http://html5demos.com"><abbr>HTML</abbr>5 Demos</a> (covering offline, storage, and web databases).</p>
<p>&mdash; Remy</p>
<h2>Nav Title (in the document outline)</h2>
<p>D Ross asked:</p>
<blockquote><p>Working on my new site and checked it with the <a href="http://gsnedders.html5.org/outliner/">outliner</a>. I&#8217;m getting an &#8220;untitled section&#8221; showing up because I don&#8217;t have a headline inside my &#8220;nav&#8221; element.</p>
<p>Is this correct? Do I really need to title my main nav?</p>
<p>If so, is adding an <code>&lt;h5&gt;</code> or something similar with the words &#8220;main navigation&#8221; good enough? If so, is hiding it with <code>display: none</code> okay?</p>
<p>Thanks,</p>
<p>DRoss</p></blockquote>
<p>Yes, &#8220;untitled section&#8221; is fine. I know it&#8217;s been suggested to the developer of the outliner that it should say &#8220;navigation&#8221; or something similar, but I&#8217;m not sure when or whether that will happen. (You&#8217;ll see the same thing with <code>&lt;aside&gt;</code> too if there&#8217;s no heading nested directly beneath the element).</p>
<p>Thanks,</p>
<p>&mdash; Rich</p>
<h2>The details element</h2>
<p>Bart asked:</p>
<blockquote><p>Hello Doctors!</p>
<p>I&#8217;d like to ask you a little help with understanding the &#8220;details&#8221; element.</p>
<p>As the W3 spec says: &#8220;The details element represents a disclosure widget from which the user can obtain additional information or controls&#8221;.</p>
<p>I&#8217;m not sure if I get it right, but I think I can use this element to put details about a post (such as date and time) and controls, including &#8220;answer&#8221;, &#8220;save&#8221; and &#8220;repost&#8221;.</p>
<p>Please tell me if I&#8217;m wrong.</p>
<p>Regards, Bart</p>
<p>PS. I love the HTML5doctor blog, it&#8217;s so important to explain how to use <abbr>HTML</abbr>5. Keep up the great work!</p></blockquote>
<p>This question triggered a flurry of responses from several of us doctors, so we&#8217;ve added them all here for you.</p>
<h3>Answer 1</h3>
<p>The spec says <code>&lt;details&gt;</code> is not appropriate for footnotes, and you could argue that post details are footnotes. Also, the <code>&lt;details&gt;</code> element has the option to show or hide its content, which suggests to me that it&#8217;s not appropriate for the post details.</p>
<p>You could possibly use a <code>&lt;section&gt;</code> or a <code>&lt;footer&gt;</code> for the post details, but I&#8217;m not clear on what you mean by &#8220;controls&#8221;. </p>
<p>For the date/time, you can use the <code>&lt;time&gt;</code> element:</p>
<pre><code>&lt;time class="published updated" datetime="2009-09-23"&gt;September 23rd, 2009&lt;/time&gt;</code></pre>
<p>Other doctors might have other opinions, but I hope this helps.</p>
<p>&mdash; Tom</p>
<h3>Answer 2</h3>
<p>Just to follow up on Tom&#8217;s reply: the user viewing your content can <em>control</em> whether or not they see the details.</p>
<p>The <code>&lt;details&gt;</code> element is an interactive element that is collapsed by default, so that only the heading is visible. The heading should be marked up in a <code>&lt;dt&gt;</code> element (if absent, it will read &#8220;Details&#8221;).</p>
<p>The control that the user agent should render (when fully supporting the <code>&lt;details&gt;</code> element) is a small triangular button to the left that, when clicked, toggles the visibility of the element&#8217;s contents.</p>
<p>If the <code>&lt;details&gt;</code> element should be open by default, it should have its <code>open</code> attribute set.</p>
<p>I would use <code>&lt;details&gt;</code> for any content that still allows the surrounding content to make sense while not necessarily needing to be seen. So in your example, I would put the metadata in the <code>&lt;details&gt;</code>, but not the &#8220;user controls&#8221; to reply, save, etc., since the user should always be able to see that they can perform these actions.</p>
<p>While the browser vendors haven&#8217;t implemented the interactive aspect of details, I, for one, will be emulating this using JavaScript.</p>
<p>I hope that helps (too!).</p>
<p>&mdash; Remy</p>
<h3>Answer 3</h3>
<p>You can also use <code>pubdate</code> as an attribute of <code>&lt;time&gt;</code>:</p>
<pre><code>&lt;time pubdate datetime="2009-09-23"&gt;September 23rd, 2009&lt;/time&gt;</code></pre>
<p><code>pubdate</code> is useful when you have two different times in the post. For example, for a future event:</p>
<pre><code>&lt;article&gt;
&lt;header&gt;
&lt;h1&gt;Gig: Hixie and the Pixies, &lt;time datetime="2010-01-01"&gt;Jan 1st 2010&lt;/time&gt;, Royal Albert Hall&lt;/h1&gt;
&lt;p>Published &lt;time datetime="2009-09-21" pubdate&gt;Sept 21, 2009&lt;/time&gt;&lt;/p&gt;
&lt;/header&gt;
&lt;p&gt;With Lachy on kazoo, Henri on Sousaphone, Pilgers on the triangle, and Hixie conducting&lt;/p&gt;
&lt;/article&gt;</code></pre>
<p>I feel a post about the <code>&lt;time&gt;</code> element coming on&hellip;</p>
<p>&mdash; Bruce</p>
<h2>More to come</h2>
<p>That wraps up this round of questions! We&#8217;d like to know what areas of <abbr>HTML</abbr>5 you&#8217;d like us to cover in future articles, so leave a comment below or <a href="http://html5doctor/contact/">send us an e-mail</a>.
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/your-questions-answered-3/" rel="bookmark" class="crp_title">Your Questions Answered #3</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-14/" rel="bookmark" class="crp_title">Your Questions #14</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/your-questions-answered-10/" rel="bookmark" class="crp_title">Your Questions Answered #10</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/your-questions-answered-4/" rel="bookmark">Your Questions Answered #4</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on December 9, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-answered-4/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Your Questions Answered #3</title>
		<link>http://html5doctor.com/your-questions-answered-3/</link>
		<comments>http://html5doctor.com/your-questions-answered-3/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 13:52:44 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Boilerplates]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Questions]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[doctype]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mime]]></category>
		<category><![CDATA[outline]]></category>
		<category><![CDATA[xmls]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1061</guid>
		<description><![CDATA[We're back with our (semi) regular round up of answering readers HTML5 related questions. Right, let's not mess about any longer and dive straight in with the questions.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re back with our (semi) regular round up of answering readers <abbr>HTML</abbr>5 related questions. Right, let&#8217;s not mess about any longer and dive straight in with the questions.</p>
<h2>Multiple use of tags</h2>
<p>Daniel Davis asked:</p>
<blockquote><p>Dear Doctor,</p>
<p>Just a quick confirmation please.</p>
<p>Am I right in thinking that nav, like header and footer, can be used more than once in a single page?  For example, surrounding a menu at the top of the page and surrounding next/previous buttons at the bottom.<br />
Come to think of it, is it fair to say that all tags except html, head and body can be used more than once?<br />
Thanks in advance, doctor.</p>
<p>I&#8217;ll be back soon about my dodgy knee.</p></blockquote>
<p>You&#8217;re correct all the elements you mention can be used more than once a page. If you see this article <a href="/the-header-element/">about the header</a> and this about <a href="/the-footer-element/">the footer</a> &#8211; they show that you can use them multiple times on a page. Also you don&#8217;t really need html, head or body tags, as all browsers will assume them anyway but it&#8217;s also safe to leave them included.</p>
<p>&mdash; Hope that clears things up <a href="/author/richc/">Rich</a> and <a href="/author/brucel/">Bruce</a></p>
<h2><abbr>HTML</abbr>5 + Javascript Client Web App</h2>
<p>Girish asked:</p>
<blockquote><p>Is it possible to create a complete client side application using HTML 5 (it will embed chat clients, stock ticker) + JavaScript, and then bundle is with underlining Firefox 3.5 engine, so that user can install it as a desktop app on Linux, and then it runs in its own window using firefox 3.5 engine. The app will store everything in local storage &#8211; like url, usernames etc, and will not interact with any local server.</p>
<p>It would pure <abbr>HTML</abbr>5 + JavaScript based client web app which would be packaged, and can be installed or launched from startup scripts.</p>
<p>Or instead of using firefox 3.5 engine, we can use Mozilla Prism to convert it to web app, and then bundle it, is it possible?</p></blockquote>
<p>Technically it <em>should</em> be possible. Certainly the <abbr>HTML</abbr>5 <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#offline">offline applications API</a> (via the manifest) gives you all that ability to create a client side app and it run locally without a web connection.</p>
<p>However, the browser is the problem.  <a href="http://prism.mozilla.com/">Prism</a> might be a good way to deploy this as a standalone app, but I don&#8217;t know if Prism is running the latest Gecko engine (or whether that comes with the JS engine, etc) &#8211; and even if it does &#8211; Firefox 3.5 currently has a pretty severe bug with the offline applications: it doesn&#8217;t work!</p>
<p>I have logged the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=501422">bug with Mozilla</a> and I know they&#8217;re working (in fact, I believe they&#8217;ve fixed it and are now testing).</p>
<p>The alternative is to use <a href="http://fluidapp.com/">Fluid</a> (a Webkit based app) &#8211; but again, that&#8217;s only if they have updated to the latest Webkit and thus including the offline applications API (that said, quickly looking at the Fluid site, their in-progress version may have the latest Webkit).</p>
<p>Regarding launch from start up scripts &#8211; you could achieve this though the custom scheme handlers (but this is just Firefox IIRC): <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#custom-handlers">http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#custom-handlers</a></p>
<p>Equally, there may be an API that you could exploit via the standalone browser, either Prism or Fluid.</p>
<p>&mdash; Good luck! <a href="http://html5doctor.com/author/remys/">Remy</a></p>
<h2>MIME or DOCTYPE, which one prevails</h2>
<p>Pedro Estébanez asked:</p>
<blockquote><p>Hello doctor,</p>
<p>I have found this site a very good resource for web developers and I thank you for your effort.</p>
<p>Now, my question:</p>
<p>There is a lot of discussion about hot to tell the browser we are using <abbr>HTML</abbr>5 or X<abbr>HTML</abbr>5 by setting the Content-Type HTTP header. But then I don&#8217;t know the true role the DOCTYPE plays (apart from keeping quirks mode from being activated and validation).</p>
<p>For example, if I compose my documents as XHTML with an according DOCTYPE and my server serves them as text/html, why XML mode is not triggered in the browser?</p>
<p>Thanks in advance.</p></blockquote>
<p>Did you see this article on the site from Bruce? <a href="/html-5-xml-xhtml-5/"><abbr>HTML</abbr>5, XML and X<abbr>HTML</abbr>5</a> and this one from Remy <a href="/html-5-boilerplates/"><abbr>HTML</abbr>5 Boilerplates</a>.</p>
<p>Also see this (linked in Bruce&#8217;s article) for some advice on using the right mime type. <a href="http://www.webstandards.org/learn/articles/askw3c/sep2003/">http://www.webstandards.org/learn/articles/askw3c/sep2003/</a>.</p>
<p>&mdash; Cheers <a href="/author/richc/">Rich</a></p>
<h2>Outline Algorithm</h2>
<p>Mike Taylor asked:</p>
<blockquote><p>In Section 4.4.11.1 of the current <abbr>HTML</abbr>5 spec, the outline algorithm is described&#8211;yet it&#8217;s not super clear in what ways this is useful to users or developers. It would be great if some more light could be shed on the topic!</p>
<p>Thanks for the awesome blog, btw.</p></blockquote>
<p>The outliner basically allows you to easily see the heading structure of a site. The outline can then figure out from the heading structure where in the outline it should sit, should you want to only parse a section of the code into another site or page for example. (I realise this isn&#8217;t totally clear). Also check out the <a href="http://gsnedders.html5.org/outliner/"><abbr>HTML</abbr>5 Outliner</a> for checking your work.</p>
<p>Bruce covered it a little bit in his <a href="/the-section-element/">section article</a> &#8211; <q>&#8220;With very few exceptions, section should not be used if there is no natural heading for it. Check your work in the HTML 5 outiner tool. If you see any instances of “untitled section” that corresponds to a section, you’re probably doing it wrong. (It’s fine for a nav or aside element to be untitled, however).&#8221;</q></p>
<p>We&#8217;ll try and cover it in more detail in a future post but I hope this helps for now, <a href="/author/richc/">Rich</a>.</p>
<h2><abbr>HTML</abbr>5 and xmlns</h2>
<p>Ad Taylor asked:</p>
<blockquote><p>
I hope this isn&#8217;t a stupid question BUT …</p>
<p>If I am using the html5 DOCTYPE and I am still using xhtml syntax do I need to define the xmlns in the html tag (i.e. xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;)?</p>
<p>Thank you for taking the time to do this.</p></blockquote>
<p>We said, Not a stupid question, but a simple answer: No!</p>
<p>&mdash; Ta <a href="http://html5doctor.com/author/brucel/">Bruce</a> (HTML5 Shrink)</p>
<h2>Developing to a changing spec</h2>
<p>Sam Rayner asked:</p>
<blockquote><p>I read the Super Friends Guide to <abbr>HTML</abbr>5 Hiccups &#8211; http://www.zeldman.com/superfriends/guide/ and it&#8217;s worried me a little.</p>
<p>I&#8217;ve recently been developing personal projects using <abbr>HTML</abbr>5 as I find I learn best &#8216;on the job&#8217; and wish to become familiar with the new spec by putting it in to practice. However, it sounds like I&#8217;ve misinterpreted bits and often used new elements such as footer in the way the Super Friends describe rather than in line with the spec.</p>
<p>I really want to continue enjoying the benefits of <abbr>HTML</abbr>5 in my own non-critical web work but it seems I run the risk of having to return to it all at a later date and amend stuff due to changes in the spec.</p>
<p>What do you think the best course of action is? Continue with 5 but keep going back and fixing old projects? &#8211; Could become a real hassle.</p>
<p>Continue with 5 and leave non-visual discrepancies as they are (the code may be slightly off but it&#8217;s styled fine)? &#8211; Goes against all of my natural instincts to do things right.</p>
<p>Return to 4 and use class names as apposed to the new elements for the time being?</p>
<p>I realise this is the risk I take developing with a developing spec but I&#8217;m worried if I wait until everything is set in stone I&#8217;ll still be using HTML4 years from now!</p>
<p>Thanks a lot,</p></blockquote>
<p>I understand your concerns with the spec changing from day to day. It&#8217;s hard to keep up with (there&#8217;s 6 of us and that&#8217;s tough enough).</p>
<p>Although I&#8217;m sure you&#8217;re aware in footers case, its <a href="/the-footer-element-update/">content model has now been changed</a> to allow it to act more like header.</p>
<p>I think essentially you have three choices for your development or a combination of the below currently:</p>
<ol>
<li>Continue working as you are with new <abbr>HTML</abbr>5 elements and change them as the spec becomes more defined</li>
<li>Use HTML4, with <abbr>HTML</abbr>5 class names (as you suggested)</li>
<li>Use only the simplified doctype and those elements that will only be benificial in the future or add progressive enchancement (e.g. inline elements such as time.)</li>
</ol>
<p>Its going to be a while until we can use <abbr>HTML</abbr>5 in development projects but in my opinion there isn&#8217;t any reason to not use it on personal projects now. You have to judge it on a case by case basis, but whichever parts you do you will be futureproofed to some extent.</p>
<p>&mdash; Cheers <a href="http://html5doctor.com/author/richc/">Rich</a></p>
<h2><abbr>HTML</abbr>5 and Browser Compatibility</h2>
<p>A lot of people ask this type of question regularly so here&#8217;s a few links that we think are useful.</p>
<ul>
<li><a href="http://a.deveria.com/caniuse/">Can I use</a></li>
<li><a href="http://molly.com/html5/html5-0709.html">Mollys <abbr>HTML</abbr>5 Table</a></li>
<li><a href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28HTML_5%29">Comparison of Layout Engines Wiki</a></li>
</ul>
<p>That about wraps up this round of questions, we&#8217;ll be publishing more soon, but in the meantime don&#8217;t be afraid to keep <a href="/ask-the-doctor/">asking the doctor about <abbr>HTML</abbr>5.</a>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<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-4/" rel="bookmark" class="crp_title">Your Questions Answered #4</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/your-questions-answered-7/" rel="bookmark" class="crp_title">Your Questions Answered #7</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-answered-3/" rel="bookmark">Your Questions Answered #3</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 22, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-answered-3/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Absent Elements and Validation</title>
		<link>http://html5doctor.com/absent-elements-and-validation/</link>
		<comments>http://html5doctor.com/absent-elements-and-validation/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 14:30:14 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Questions]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[WAI-ARIA]]></category>
		<category><![CDATA[doctype]]></category>
		<category><![CDATA[HTML 5]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=777</guid>
		<description><![CDATA[We received the below question from Guy Carberry who was wondering what affect changing the doctype on your <abbr>HTML</abbr> or <abbr>XHTML</abbr> pages to the <abbr>HTML</abbr> 5 doctype will have on those elements that are deprecated current draft.]]></description>
			<content:encoded><![CDATA[<p>We received the below question from Guy Carberry who was wondering what effect changing the doctype on your <abbr>HTML</abbr> or <abbr>XHTML</abbr> pages to the <abbr>HTML</abbr> 5 doctype will have on those elements that are deprecated current draft.</p>
<h2>The Question</h2>
<p>There are several aspects to consider from this question so lets start by taking a look at Guys question in full.</p>
<blockquote><p>
Jeremy Keith says that we can change the Doctype declaration on XHTML 1.0 syntax pages to <cod>&lt;!DOCTYPE html&gt;</code> and it will immediately become HTML 5.</p>
<p>I'm a bit confused about what that means for the Absent and changed elements and attributes info detailed here: <a href="http://www.w3.org/TR/html5-diff/#absent-elements">http://www.w3.org/TR/html5-diff/#absent-elements</a></p>
<p><q>"Some attributes from HTML 4 are no longer allowed in HTML5. If they need to have any impact on user agents for compatibility reasons it is defined how they should work in those scenarios."</q></p>
<p>So if this is that case, how can you switch the doctype declarations and all be fine?</p>
<p>Thanks for your help,</p>
<p>Guy.
</p></blockquote>
<h2>The Doctors Response</h2>
<p>In answering the question we will need to break the question down into the following:</p>
<ol>
<li>Which elements or attributes are deprecated?</li>
<li>Do I use any of those elements or attributes on my site?</li>
<li>How much do I need to worry about validation?</li>
<li>What effect will this have for backwards compatibility?</li>
<li>Can my content be accessed in all my target browsers and user agents?</li>
</ol>
<p>Lets consider each of these in some more detail below.</p>
<h3>1. Which elements or attributes are deprecated?</h3>
<p>The elements deprecated (from HTML 4.01) from the <abbr>HTML</abbr>5 specification are: <code>basefont, big, center, font, strike, tt, frame, frameset, noframes, acronym, applet, isindex, dir</code></p>
<p>You can find a list of those <a href="http://www.w3.org/TR/html5-diff/#absent-elements">elements</a> and <a href="http://www.w3.org/TR/html5-diff/#absent-attributes">attributes</a> along with detailed reasons of why they've been removed by reading <a href="http://www.w3.org/TR/html5-diff"><abbr>HTML<abb>5 differences from <abbr>HTML</abbr>5</a>.</p>
<h3>2. Do I use any of those elements or attributes on my site?</h3>
<p>If your site uses any of the above named elements or attributes you may consider changing them to more semantic elements as introduced in <abbr>HTML</abbr>5. Alternatively you may decide to remove them and use <abbr>CSS</abbr> for presentation in the case of <code>&lt;font&gt;</code> or <code>&lt;center&gt;</code>.</p>
<p>Guy told use that he works for a large university. The site uses a large number of <code>&lt;acronym&gt;</code> tags which have been removed from <abbr>HTML</abbr> 5 as detailed above. To solve this issue for Guy, I feel he has three options if he wishes to make the site: <abbr>HTML</abbr>5:</p>
<ol>
<li>Change the doctype to <abbr>HTML</abbr>5 and leave the <code>&lt;acronym&gt;</code> elements in. (Bear in mind the <abbr>HTML</abbr> won't validate)</li>
<li>Change the doctype to <abbr>HTML</abbr>5 edit the <code>&lt;acronym&gt;</code> elements to become <code>&lt;abbr&gt;</code> elements as advised by the specification</li>
<li>Do nothing and leave the site as <abbr>HTML</abbr> 4.01 or <abbr>XHTML</abbr></li>
</ol>
<p>It's difficult to be able to advise Guy on which option he should choose without knowing the full extent of the effort involved to implement these solutions or knowing the sites goals and project teams views on validation. Speaking of validation, the whole area is a minefield and it's what we'll attempt to cover next.</p>
<h3>3. How much do I need to worry about validation?</h3>
<p>While validation is undoubtedly important for your markup and your <abbr>CSS</abbr>, in my opinion it isn't crucial to a site. Allow me to explain, we recently received a couple of emails pointing out that this site doesn't validate. While there were some errors that have now been corrected, a primary reason why is the use of <abbr title="Accessible Rich Internet Applications">ARIA</abbr> roles in the markup. These attributes currently aren't allowed in the current specification, however there is work underway to make this happen.</p>
<p>To illustrate this point let's look at Google, the search giant. If you look at the source on Google's search pages you'll see they use the <abbr>HTML</abbr>5 doctype.</p>
<pre><code>&lt;!DOCTYPE html&gt;</code></pre>
<aside class="sidenote"><q>HTML5 takes a "pave the cowpaths" approach to development</q></aside>
<p>However, those pages don't validate because they use the <code>&lt;font&gt;</code> and <code>&lt;center&gt;</code> elements amongst others things that we already know have been removed from the specification. Does this mean that users stop visiting Google? <em>No</em>.</p>
<p>Remember too that the specification is yet to be finalised and may still be changed (thus breaking you're perfectly valid docments), in partnership with this changes to the specification may not immediately take be implemented in the validators.  We also need to bear in mind that <abbr>HTML</abbr>5 takes a "pave the cowpaths" approach to development, meaning that the Hixie, et al will look at what authors already do and improve upon it. </p>
<h3>4. What effect will this have for backwards compatibility?</h3>
<p>Leading on from the point about Google as mentioned previously we know Googles site not validating doesn't matter but is it still backwards compatible? <em>Yes</em>. As far as we know, all the browsers support the <code>&lt;font&gt;</code> tag.  It's the validators that don't.  If you want to use an antiquated element you can do, the browser will still handle it - it just won't validate.</p>
<p>In terms of backwards compatibility there is no reason why you couldn't start using new <abbr>HTML</abbr> 5 elements in your <abbr>HTML</abbr> 4.01 or <abbr>XHTML</abbr> 1.x documents, it could even be described as progressive enhancement. For example, why not include the <code>&lt;video&gt;</code> element? It <em>won't</em> validate but maybe that doesn't matter? The browser will still be able to render video, hence <q>"paving the cowpaths"</q>. Having said that if you're going to the effort of including new elements why not go the whole hog and change the doctype too?</p>
<h3>5. Can my content be accessed in all my target browsers and user agents?</h3>
<p>Again to look at Google, it still renders in older browswers and devices but to all intents and purposes it's <abbr>HTML</abbr>5. Another aspect that the specification defines is that new features should work in or not break in older browsers.</p>
<p><a href="/author/remys/">Remy</a> pointed out in a response to Guy that</p>
<blockquote><p>
Remember that the browser is still going to handle this, regardless of whether <abbr>HTML</abbr>5 supports this or not. Just like and <abbr>XHTML</abbr> document although doesn't validate with frames, it still renders fine and still supports frames.
</p></blockquote>
<p>So from that we can conclude that browsers will still render deprecated elements or practices. </p>
<h2>Summary</h2>
<p>To wrap up I think we can answer Guys question by saying yes, changing the doctype will make your site <abbr>HTML</abbr>5, but whether or not it validates is in essence an entirely personal or business decision. Whether this means you are making use of all the benefits of <abbr>HTML</abbr>5's new elements, javascript API's or offline storage is a whole different subject.
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/html-5-xml-xhtml-5/" rel="bookmark" class="crp_title">HTML 5 + XML = XHTML 5</a></li>
<li><a href="http://html5doctor.com/html-5-boilerplates/" rel="bookmark" class="crp_title">HTML5 Boilerplates</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/how-to-use-html5-in-your-client-work-right-now/" rel="bookmark" class="crp_title">How to use HTML5 in your client work right now</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-3/" rel="bookmark" class="crp_title">Your Questions Answered #3</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/absent-elements-and-validation/" rel="bookmark">Absent Elements and Validation</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on August 25, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/absent-elements-and-validation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Legend not such a legend anymore</title>
		<link>http://html5doctor.com/legend-not-such-a-legend-anymore/</link>
		<comments>http://html5doctor.com/legend-not-such-a-legend-anymore/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 12:00:26 +0000</pubDate>
		<dc:creator>Remy Sharp</dc:creator>
				<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[Structure]]></category>
		<category><![CDATA[details]]></category>
		<category><![CDATA[figure]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[legend]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=646</guid>
		<description><![CDATA[Lately I decided I was going to recreate the interactive features of the details element using JavaScript (apparently the same day as fellow Brightonian Jeremy Keith). However I ran in to some very serious issues with the tag, so serious, in it’s current state, it’s unusable.]]></description>
			<content:encoded><![CDATA[<p>Lately I decided I was going to recreate the interactive features of the <code>details</code> element using JavaScript (apparently <a href="http://twitter.com/adactio/status/2869549874">the same day</a> as fellow Brightonian <a href="http://adactio.com/" title="Adactio: Jeremy Keith">Jeremy Keith</a>).</p>

<p>However I ran in to some very serious issues with the tag, so serious, in it&#8217;s current state, it&#8217;s unusable.</p>

<p><span id="more-646"></span></p>

<h2>Overview of the details element</h2>

<p>The <code>details</code> element, by default, is a collapsed element whose summary, or label, is the first child <code>legend</code> (if no <code>legend</code> is used, the UA provides a default, such as &#8220;Details&#8221;), with a triangular button to indicate it&#8217;s current open state.</p>

<p>If you include the <code>open</code> attribute, then the element is open by default.  In theory, you could attach a click event to the legend, and switch the <code>open</code> attribute.</p>

<p>The markup would roughly be this:</p>

<pre><code>&lt;details open=&quot;open&quot;&gt;
  &lt;legend&gt;Terms &amp; Conditions&lt;/legend&gt;
  &lt;p&gt;You agree to xyz, etc.&lt;/p&gt;
&lt;/details&gt;</code></pre>

<p>Here&#8217;s the details test page I was working from: <a href="http://remysharp.com/demo/details.html">HTML 5 details test</a></p>

<h2>The issues</h2>

<p>The biggest problem, and the show stopper for me, is that the browser&#8217;s treatment of the <code>legend</code> element completely breaks this markup pattern &#8211; this is true for <strong>all</strong> the major browsers: Opera, Safari, Firefox and IE (tested in all the latest and some older browsers).  I&#8217;ll go in these issues in detail in a moment.</p>

<p>Other problems include:</p>

<ul>
<li>Styling the legend element is exceptionally difficult, particularly positioning</li>
<li>Using the <a href="http://www.whatwg.org/" title="Web Hypertext Application Technology Working Group">WHATWG</a> <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#the-details-element-0">guidelines to styling</a> the <code>details</code> element prove both difficult to interpret and difficult to implement.</li>
<li>When using CSS to style the open state of the <code>details</code> element using: <code>details[open] { height: auto; }</code>, meant that once I changed the open state using JavaScript, it wouldn&#8217;t trigger the browser to redraw (as it would if I had added a class). I&#8217;ve <a href="http://twitter.com/rem/status/2178972149">run in to this before</a>, CSS 2.1 is styling source, not the DOM.</li>
</ul>

<h2>Legend treatment</h2>

<p>Surprisingly Firefox is the worst one out in these issues, the rest of the browsers have fairly same treatment of the issue.  In the screenshots, I&#8217;ve included a <code>fieldset</code> and nested <code>legend</code> for reference.</p>

<h3>Internet Explorer</h3>

<p>IE7 &#038; IE8 closes the <code>legend</code> element it encounters when it&#8217;s not inside a <code>fieldset</code> element and move it&#8217;s contents out to an adjacent text node.</p>

<p>What&#8217;s also strange, is that looking at the DOM it also creates another empty(?) closed <code>legend</code> element after that text node.  It doesn&#8217;t have any effect, but just looked odd:</p>

<p><img src="http://remysharp.com/wp-content/uploads/2009/07/ies-details-element-treatment.jpg" alt="IE's details element treatment" /></p>

<h3>Opera</h3>

<p>Opera (9 &#038; 10b) is very similar to IE in it&#8217;s treatment of the <code>legend</code> in the details element, except it doesn&#8217;t create the second closing <code>legend</code> node.  It just closes the <code>legend</code>, and creates the adjacent text node.</p>

<h3>Safari</h3>

<p>Safari simply strips the <code>legend</code> all together out of the DOM.  So much so, that if you open the web inspector, then the error console, you&#8217;ll see it warning out that it&#8217;s encountered an illegal element, ignoring it, then encountering the closing tag, so it ignores that too.  You&#8217;re left with just the text node.</p>

<h3>Firefox</h3>

<p>The best for last.  Firefox goes one step beyond the other browsers.  It assumes you&#8217;ve forgotten to include the <code>fieldset</code> element.  So when it hits the <code>legend</code> element, Firefox inserts an opening <code>fieldset</code> up until it finds (I believe) the closing <code>fieldset</code> element, which obviously it <em>doesn&#8217;t</em> so the result is the rest of the DOM, after the first illegally placed <code>legend</code> ends up eaten by <code>fieldset</code> element, which leaves my DOM in a mess:</p>

<p><img src="http://remysharp.com/wp-content/uploads/2009/07/firefox-details-treatment.jpg" alt="Firefox details treatment" /></p>

<h2>Impact on other elements</h2>

<p><code>details</code> isn&#8217;t the only element that reuses the <code>legend</code> element for labelling, the <code>figure</code> element also is <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-0.html#the-figure-element">supposed to support</a> the <code>legend</code> element.  The result is obviously going to be the same.</p>

<h2>Conclusion</h2>

<p>We can&#8217;t style the legend element when the text is being thrown out by all the browsers, and Firefox&#8217;s DOM mangling is just too painful to look at.</p>

<p>This basically means that we can&#8217;t, in any reasonable amount of time, use the <code>legend</code> element inside both the <code>details</code> and <code>figure</code> element in the spec&#8217;s current state.</p>

<p>For me, I&#8217;ll be using an alternative element, probably just a <code>p</code> element styled to look like a <code>legend</code>, but that&#8217;s really not the point.  Ideas anyone?</p>

<p>It turns out we weren&#8217;t the only ones looking at this and <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2009-July/021494.html">Ian Hickson</a> has responded on the issue:</p>

<blockquote cite="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2009-July/021494.html"><p>My plan here is to continue to wait for a while longer to see if the parsing issues can get ironed out (the HTML5 parser in Gecko for instance solves this problem for Firefox). If we really can&#8217;t get past this, we&#8217;ll have to introduce a new element, but I&#8217;m trying to avoid going there.</p></blockquote>

<p>It&#8217;s fine to think that Gecko will update, but it&#8217;s IE that I&#8217;m worried about, they <em>won&#8217;t</em> turn out their render engine, and the result is we&#8217;ll <em>have</em> to avoid using the <code>legend</code> in any element other than <code>fieldset</code>.<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/dd-details-wrong-again/" rel="bookmark" class="crp_title">dd-details wrong again</a></li><li><a href="http://html5doctor.com/summary-figcaption-element/" rel="bookmark" class="crp_title">Hello, summary and figcaption elements</a></li><li><a href="http://html5doctor.com/september-html5-spec-changes/" rel="bookmark" class="crp_title">September HTML5 spec changes</a></li><li><a href="http://html5doctor.com/the-figure-figcaption-elements/" rel="bookmark" class="crp_title">The figure &#038; figcaption elements</a></li><li><a href="http://html5doctor.com/the-details-and-summary-elements/" rel="bookmark" class="crp_title">The details and summary elements</a></li></ul></div></p>
<p><a href="http://html5doctor.com/legend-not-such-a-legend-anymore/" rel="bookmark">Legend not such a legend anymore</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 31, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/legend-not-such-a-legend-anymore/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Native Audio in the browser</title>
		<link>http://html5doctor.com/native-audio-in-the-browser/</link>
		<comments>http://html5doctor.com/native-audio-in-the-browser/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 15:00:29 +0000</pubDate>
		<dc:creator>Mark Boas</dc:creator>
				<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[codecs]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=497</guid>
		<description><![CDATA[Until very recently the ability to play any type of audio within a browser involved using Adobe Flash or other browser plugins. Although Adobe's Flash player is without doubt the most ubiquitous of these, most developers and designers would agree it is better not to rely on a plugin at all. Now thanks to HTML 5 and the browsers that implement its audio tag we can play audio natively within the browser.]]></description>
			<content:encoded><![CDATA[<p>Until recently, the ability to play any type of audio within a browser involved using Adobe Flash or other browser plugins. Although Adobe's Flash player is unquestionably the most ubiquitous of these, most developers and designers would agree that it's better not to rely on a plugin at all.</p>

<h2>Enter <abbr>HTML</abbr>5 <code>&lt;audio&gt;</code></h2>

<p>One of the most exciting and long-awaited features in <abbr>HTML</abbr>5 the <code>&lt;audio&gt;</code> element, enabling native audio playback within the browser. We can take advantage of this now as nearly all of the major browsers support it &mdash; currently Firefox, Chrome, Safari and Opera, but they are soon to be joined by Internet Explorer 9 which is currently in beta. For browsers that don't support audio natively, we can easily fallback to Flash.</p>

<h3>According to spec</h3>

<p>Currently, the <abbr>HTML</abbr>5 spec defines five attributes for the <code>&lt;audio&gt;</code> element:</p>

<ol>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-media-src"><code>src</code></a> &mdash; a valid &lt;abbr&gt;URL&lt;/abbr&gt; specifying the  content source</li>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-media-autoplay"><code>autoplay</code></a> &mdash; a boolean specifying whether the  file should play as soon as it can</li>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-media-loop"><code>loop</code></a> &mdash; a boolean specifying whether the file  should be repeatedly played.</li>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-media-controls"><code>controls</code></a> &mdash; a boolean specifying whether the  browser should display its default media controls</li>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-media-preload"><code>preload</code></a> &mdash; none / metadata / auto &mdash;  where 'metadata' means preload just the metadata and 'auto' leaves the  browser to decide whether to preload the whole file.</li>
</ol>

<p>Note preload supercedes autobuffer in the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-media-preload">latest  HTML5 spec</a>. Previously autobuffer took a boolean value specifying  whether the file is to be buffered in advance. Currently, browsers are making the transition from autobuffer to preload so we suggest that you use both attributes for the time being.</p>

<p>Incidentally these are the same attributes defined for the <code>&lt;video&gt;</code> element.</p>

<h3>Examples</h3>

<p>Let's take a couple of these attributes and create a simple example that will play an audio file:</p>

<pre><code>&lt;audio src="elvis.ogg" controls preload="auto" autobuffer&gt;&lt;/audio&gt;
</code></pre>

<p>(This example will work for the latest versions of Firefox, Chrome and Opera. You'll need to replace the Ogg file with an MP3 to get it working in Safari.)</p>

<p>Of course, the spec is not finalised, and there isn't yet a consensus on which codecs to support. This table details the codecs supported by today's browsers:</p>

<table>
  <caption>Codec support in modern desktop browsers</caption>
  <thead>
    <tr>
      <th>Browser</th>
      <th>Ogg Vorbis</th>
      <th>MP3</th>
      <th>WAV</th>
    </tr>
  </thead>
  <tbody>
    <td>FireFox 3.6+</td>
      <td>✓</td>
      <td></td>
      <td>✓</td>
    </tr>
    <tr>
      <td>Safari 5+</td>
      <td></td>
      <td>✓</td>
      <td>✓</td>
    </tr>
    <tr>
      <td>Chrome 6</td>
      <td>✓</td>
      <td>✓</td>
      <td></td>
    </tr>
    <tr>
      <td>Opera 10.5+</td>
      <td>✓</td>
      <td></td>
      <td>✓</td>
    </tr> 
    <tr>
      <td>Internet Explorer 9 (beta)</td>
      <td></td>
      <td>✓</td>
      <td>✓</td>
    </tr>
  </tbody>
</table>   

<p>To create our own controls, we can use the <abbr>API</abbr> methods defined by the spec:</p>

<ul>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom-media-play"><code>play()</code></a> &mdash; plays the audio</li>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom-media-pause"><code>pause()</code></a> &mdash; pauses the audio</li>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom-navigator-canplaytype"><code>canPlayType()</code></a> &mdash; interrogates the browser to establish whether the given mime type can be played</li>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom-media-buffered"><code>buffered()</code></a> &mdash; attribute that specifies the start and end time of the buffered part of the file</li>
</ul>

<h2>Use the Source</h2>

<p>The best way to coerce browsers into playing audio (or video, for that matter) is to use the <code>&lt;source&gt;</code> element. The browser will try to load the first audio source, and if it fails or isn't supported, it will move on to the next audio source. In addition, we can embed a Flash player if all else fails:</p></p>

<pre><code>&lt;audio controls preload="auto" autobuffer&gt; 
  &lt;source src="elvis.mp3" /&gt;
  &lt;source src="elvis.ogg" /&gt;
  &lt;!-- now include flash fall back --&gt;
&lt;/audio&gt;
</code></pre>

<p>One caveat, though: you may need to be careful about the order of the <code>&lt;source&gt;</code> elements. At the time of going to press issues have been reported with Mobile Safari and older versions of Firefox.</p>

<h2>Cross-Browser Implementation</h2>

<p>When we created <a href="http://happyworm.com/jquery/jplayer">jPlayer</a>, an audio player plugin for jQuery, we were attempting to address some of the limitations of the current crop of Flash-based audio players. Many relied on Flash to implement the player's graphical interface, effectively isolating the player from the rest of the web design process.</p>

<p>The original jPlayer relied on Flash to play the actual audio while allowing the look and feel to be styled via <abbr>HTML</abbr> and <abbr>CSS</abbr>. With growing support for <abbr>HTML</abbr>5 in modern browsers, we were inspired to break our Flash dependency and use native audio when it was supported.</p>

<p>The most significant issue is the cross-browser implementation, where lack of a common supported audio format among browsers causes complications. If developers want to take full advantage of all browsers that support <abbr>HTML</abbr>5 audio, they'll need to create both MP3 and Ogg (and in Opera's case, WAV) versions of the audio file they want to stream!</p>

<p>Since the <abbr>HTML</abbr>5 standard is still a work in progress, several aspects of the <code>&lt;audio&gt;</code> element vary from browser to browser. For example, there seems to be no way to determine the load progress of an audio file in all browsers as this relies on <a href="https://developer.mozilla.org/en/nsIDOMHTMLMediaElement"><code>buffered</code></a> DOM attribute being implemented. Chrome has implemented <a href="https://developer.mozilla.org/en/nsIDOMHTMLMediaElement"><code>buffered</code></a>, in Safari it's there but seems to behave slightly differently, current versions of Opera and Firefox however don't support it (<a href="http://hacks.mozilla.org/2010/08/html5-video-buffered-property-available-in-firefox-4/">although Firefox 4 beta does</a>).</p>

<p>Although these inconsistencies aren't showstoppers, in order to compete effectively with plugin-based solutions, we believe any <abbr>HTML</abbr>5 audio implementation should be consistent across all browsers and match current implementations feature for feature.</p>

<h3>JavaScript solutions</h3>

<p>If we intend to take advantage of each browser's audio capabilities, we need to create different solutions for different browsers. We could use browser sniffing, but considering the rapidly changing landscape, it's better to check what capabilities a particular browser supports and adapt accordingly.</p>

<p>To demonstrate this "feature sniffing", we've created a rough and ready <a href="http://www.happyworm.com/jquery/jplayer/HTML5.Audio.Support"><abbr>HTML</abbr>5 audio checker</a>.</p>

<p>Using JavaScript, you can check for audio tag support:</p>

<pre><code>// returns a boolean
var audioTagSupport = !!(document.createElement('audio').canPlayType);
</code></pre>

<p>or check file type compatibility:</p>

<pre><code>// Need to check the canPlayType first or an exception
    // will be thrown for those browsers that don't support it      

    var myAudio = document.createElement('audio'); 
    
    if (myAudio.canPlayType) {
      
       // Currently canPlayType(type) returns: "", "maybe" or "probably" 

       var canPlayMp3 = !!myAudio.canPlayType &#038;& "" != myAudio.canPlayType('audio/mpeg');
       var canPlayOgg = !!myAudio.canPlayType &#038;& "" != myAudio.canPlayType('audio/ogg; codecs="vorbis"');
    }</code></pre>

<p>Note that to change the <code>src</code> attribute of an audio object or element, you'll need to recreate the object or element with the new value for its <code>src</code> attribute or alternatively change the <code>src</code> URL and then issue a myAudio.load() command. </p>

<p>So, to create a solution that takes full advantage of <abbr>HTML</abbr>5 audio, you'll typically need to:</p>

<ol>
<li>check for <abbr>HTML</abbr>5 audio support, and if not present, fall back on Flash,</li>
<li>check the level of <abbr>HTML</abbr>5 audio support and adapt your code accordingly for each browser, and</li>
<li>check what file types are supported and link to appropriate formats of the files.</li>
</ol>

<h2>The Road Ahead</h2>

<p>Although <abbr>HTML</abbr>5 audio is a relatively immature part of the standard, if recent trends continue and users upgrade to the latest versions of Safari, Firefox, Chrome and Opera, browser support is likely above 30% today. This is a significant chunk of the browser market that will no longer need to rely on Adobe's Flash, Microsoft's Silverlight, or any other browser plugin for audio support. Add to this the fact that Internet Explorer 9 supports <abbr>HTML</abbr>5 audio and we could easily see the majority of installed browsers supporting it in the very near future.</p>

<p>And when you consider that mobile and other lower-spec devices such as tablets are choosing to support <abbr>HTML</abbr>5 audio, you begin to paint a picture of how important native audio support is becoming.</p>

<h2>Further reading:</h2>

<ul>
<li><p><a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2009-June/020620.html">&#91;whatwg&#93; Codecs for <code>&lt;audio&gt;</code> and <code>&lt;video&gt;</code></a></p></li>
<li><p><a href="http://stackoverflow.com/questions/1007223/which-browsers-support-the-html-5-audio-tag-on-windows-today/1009015#1009015">Which browsers support <abbr>HTML</abbr>5 <code>&lt;audio&gt;</code> on Windows today?</a></p></li>
</ul>

<p><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/html5-audio-the-state-of-play/" rel="bookmark" class="crp_title">HTML5 Audio — The State of Play</a></li><li><a href="http://html5doctor.com/the-video-element/" rel="bookmark" class="crp_title">The video element</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/youtube-and-vimeo-support-html5-video/" rel="bookmark" class="crp_title">YouTube and Vimeo support HTML5 Video</a></li><li><a href="http://html5doctor.com/your-questions-answered-4/" rel="bookmark" class="crp_title">Your Questions Answered #4</a></li></ul></div></p>
<p><a href="http://html5doctor.com/native-audio-in-the-browser/" rel="bookmark">Native Audio in the browser</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 29, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/native-audio-in-the-browser/feed/</wfw:commentRss>
		<slash:comments>148</slash:comments>
		</item>
		<item>
		<title>HTML5 Reset Stylesheet</title>
		<link>http://html5doctor.com/html-5-reset-stylesheet/</link>
		<comments>http://html5doctor.com/html-5-reset-stylesheet/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 14:00:42 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Boilerplates]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[reset]]></category>
		<category><![CDATA[stylesheet]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=622</guid>
		<description><![CDATA[We've had a number of people asking about templates, boilerplates and styling for <abbr>HTML</abbr> 5 so to give you all a helping hand and continue on from those basic building blocks that Remy talked about last week I've created a HTML 5 reset stylesheet for you to take away and use, edit, amend and update in your projects.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve had a number of people ask about templates, boilerplates, and styling for <abbr>HTML</abbr> 5. Last week, <a href="/author/remys/">Remy</a> introduced some <a href="/html-5-boilerplates/">basic boilerplates for HTML 5</a>, so to keep the momentum going, I&#8217;ve modified <a href="http://meyerweb.com/eric/tools/css/reset/">Eric Meyer&#8217;s <abbr>CSS</abbr> reset</a> for you to use in your HTML 5 projects.</p>

<h2>The code</h2>

<p>Let&#8217;s start with the complete <abbr>CSS</abbr> stylesheet:</p>

<pre><code>/* 
html5doctor.com Reset Stylesheet
v1.6.1
Last Updated: 2010-09-17
Author: Richard Clark - http://richclarkdesign.com 
Twitter: @rich_clark
*/

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
    margin:0;
    padding:0;
    border:0;
    outline:0;
    font-size:100%;
    vertical-align:baseline;
    background:transparent;
}

body {
    line-height:1;
}

article,aside,details,figcaption,figure,
footer,header,hgroup,menu,nav,section { 
    display:block;
}

nav ul {
    list-style:none;
}

blockquote, q {
    quotes:none;
}

blockquote:before, blockquote:after,
q:before, q:after {
    content:'';
    content:none;
}

a {
    margin:0;
    padding:0;
    font-size:100%;
    vertical-align:baseline;
    background:transparent;
}

/* change colours to suit your needs */
ins {
    background-color:#ff9;
    color:#000;
    text-decoration:none;
}

/* change colours to suit your needs */
mark {
    background-color:#ff9;
    color:#000; 
    font-style:italic;
    font-weight:bold;
}

del {
    text-decoration: line-through;
}

abbr[title], dfn[title] {
    border-bottom:1px dotted;
    cursor:help;
}

table {
    border-collapse:collapse;
    border-spacing:0;
}

/* change border colour to suit your needs */
hr {
    display:block;
    height:1px;
    border:0;   
    border-top:1px solid #cccccc;
    margin:1em 0;
    padding:0;
}

input, select {
    vertical-align:middle;
}</code></pre>

<h2>So what&#8217;s new?</h2>

<p>Quite a bit! The next few sections explain what I changed and why I changed it.</p>

<h3>The basics</h3>

<p>I started by removing elements that have been deprecated from the <abbr>HTML</abbr> 5 specification, like <code>&lt;acronym&gt;</code>, <code>&lt;center&gt;</code> and <code>&lt;big&gt;</code>. (We&#8217;ll cover deprecated elements in more detail in another post). I also added new <abbr>HTML</abbr> 5 elements, like <code>and</code>, in order to remove any default padding, margin, and borders. I&#8217;ve also added an explicit <code>display:block</code> property for elements that are required to render as blocks.</p>

<p>I also removed the explicit unstyling of the <code>:focus</code> pseudo-class. There are two reasons for this. First, by declaring <code>outline:0</code>, you remove the focus identifier for keyboard users. Second, Eric released his stylesheet in good faith that people would explicitly style <code>:focus</code>, but they generally don&#8217;t, so it&#8217;s safer to leave the default <code>:focus</code> styles in place. (I also set defaults for <code>&lt;ins&gt;</code>, since I don&#8217;t think that got updated very often either.)</p>

<p>I&#8217;ve left the default list styles in place simply as a personal preference. I tend to add the list style back when using Eric&#8217;s reset anyway. I have, however, included <code>nav ul {list-style:none;}</code> to remove those pesky bullets from your navigation. </p>

<h3>Using attribute selectors</h3>

<p>You&#8217;ll notice that I&#8217;ve included attribute selectors for <code>&lt;abbr&gt;</code> and <code>&lt;dfn&gt;</code>. This way, the style will only appear <em>if</em> there is a title attribute on the element. This is primarily for accessibility. For example, we use <code>&lt;abbr&gt;</code> regularly on this site but don&#8217;t always include a title attribute. We think it&#8217;s safe to assume all of our readers (no matter what device they&#8217;re using) know what <abbr>HTML</abbr> stands for. We do still use the <code>&lt;abbr&gt;</code> element to make sure screen readers read the text as H-T-M-L rather than struggling to pronounce &#8220;HTML&#8221;.</p>

<h3>What&#8217;s that bit about mark?</h3>

<p><code>&lt;mark&gt;</code> is a new element introduced in <abbr>HTML</abbr> 5 used to (you guessed it) mark text in a document. According to the spec: <q>&#8220;The mark element represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context.&#8221;</q>. I anticipate it will be used for highlighting phrases in search results and other similar purposes. We&#8217;ll post more on <code>&lt;mark&gt;</code> soon.</p>

<h2>Where are all those application elements?</h2>

<p>Application elements is a term I&#8217;ve loosely used to describe elements like menu, etc. These elements are more likely found in web <em>apps</em> than web <em>sites</em>. I left these out since, at the time of writing, browsers implement barely any of what was &#8220;Web Applications 1.0&#8243;. Also, this stylesheet is intended primarily for authors serving their pages as <code>text/html</code>, not <abbr>XML</abbr>.</p>

<h2>Go grab it</h2>

<p>The stylesheet is released <del datetime="2010-12-16T17:21:13+00:00">under a Creative Commons license</del> <ins datetime="2010-12-16T17:21:13+00:00">in the public domain</ins>, so you can use it for both personal and commercial work. I thought I&#8217;d let Google take care of the hosting, so go <a href="http://code.google.com/p/html5resetcss/downloads/list">grab it from Google Code</a> and let us know about any improvements you make!</p>

<ul>
<li><a href="http://code.google.com/p/html5resetcss/downloads/list">HTML 5 Reset Stylesheet</a><div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/small-hr-element/" rel="bookmark" class="crp_title">The small &amp; hr 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/u-element/" rel="bookmark" class="crp_title">The return of the u element</a></li><li><a href="http://html5doctor.com/css3-pseudo-classes-and-html5-forms/" rel="bookmark" class="crp_title">CSS3 Pseudo-Classes and HTML5 Forms</a></li><li><a href="http://html5doctor.com/avoiding-common-html5-mistakes/" rel="bookmark" class="crp_title">Avoiding common HTML5 mistakes</a></li></ul></div></li>
</ul>
<p><a href="http://html5doctor.com/html-5-reset-stylesheet/" rel="bookmark">HTML5 Reset Stylesheet</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 27, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/html-5-reset-stylesheet/feed/</wfw:commentRss>
		<slash:comments>218</slash:comments>
		</item>
		<item>
		<title>2022, or when will HTML 5 be ready?</title>
		<link>http://html5doctor.com/2022-or-when-will-html-5-be-ready/</link>
		<comments>http://html5doctor.com/2022-or-when-will-html-5-be-ready/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 14:19:00 +0000</pubDate>
		<dc:creator>Remy Sharp</dc:creator>
				<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[Ian Hickson]]></category>
		<category><![CDATA[W3C]]></category>
		<category><![CDATA[WHATWG]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=548</guid>
		<description><![CDATA[Aside from being the year Queen Elizabeth II will celebrate her Platinum Jubilee, assuming she's still kicking around, 2022 is the year that's been inappropriately linked with HTML 5 in the minds of a lot of our community.  I understand why someone might think that, but it's wrong.  *2022* was misinterpreted as the year <abbr>HTML</abbr> 5 would be ready.  That's wrong.  <abbr>HTML</abbr> 5 is ready  <strong>today</strong>.]]></description>
			<content:encoded><![CDATA[<p>Aside from being the year Queen Elizabeth II will celebrate her Platinum Jubilee, assuming she&#8217;s still kicking around, 2022 is the year that&#8217;s been inappropriately linked with HTML 5 in the minds of a lot of our community.  </p>

<p>I understand why someone might think that, but it&#8217;s wrong.  <em>2022</em> was misinterpreted as the year <abbr>HTML</abbr> 5 would be ready.  That&#8217;s wrong.  <abbr>HTML</abbr> 5 is ready  <strong>today</strong>.</p>

<p>In an <a href="http://blogs.techrepublic.com.com/programming-and-development/?p=718">interview by Tech Republic</a>, for a techie audience, <a href="http://ln.hixie.ch/" title="Hixie's Natural Log">Ian Hickson</a>, the editor of the HTML 5 working draft, was asked to give a timeline of the HTML 5 recommendation.</p>

<p>One date <em>should</em> have come out of that interview, but another, much further away did instead: 2022 &#8211; the date of the final proposed recommendation, which actually translates to: </p>

<blockquote>
  <p>require at least two browsers to completely pass [<abbr>HTML</abbr> 5 test suites]</p>
</blockquote>

<p>Let&#8217;s put this in context of another spec that has taken a very long time: <abbr>CSS</abbr> 2.1.</p>

<p><abbr>CSS</abbr> 2.1 is <abbr>CSS</abbr> that I&#8217;m <em>certain</em> you&#8217;re familiar with.  I&#8217;m <em>certain</em> you use it day to day without any thought as to whether it&#8217;s a completed spec.  </p>

<p>It&#8217;s been in development for over 10 years, and it&#8217;s <em>only just</em> become a candidate recommendation (23rd April 2009).  </p>

<p>That said, it <strong>doesn&#8217;t</strong> have two browsers completely supporting it.  Only Internet Explorer 8 supports the full <abbr>CSS</abbr> 2.1 spec.  </p>

<p>Did that stop you from using <abbr>CSS</abbr> 2.1?  I suspect not.  Will that stop us from using <abbr>HTML</abbr> 5?  It certainly shouldn&#8217;t. <abbr>HTML</abbr> 5 is available and ready to be used today.</p>

<h2>What <em>is</em> the important <abbr>HTML</abbr> 5 date?</h2>

<p><strong>October 2009</strong>.  </p>

<p>This October is the <em>last call</em> for the <abbr>HTML</abbr> 5 working draft.</p>

<p>That means, that issues with the spec, enhancements, bugs, anything, it all needs to be in and submitted and written in to the spec for October <em>this year</em> (it can go through reiterations, the this is the main deadline).</p>

<p>The <abbr>WHATWG</abbr> is completely open for <em>anyone</em> to contribute their ideas and suggestions.</p>

<p>You can sign up to the <a href="http://www.whatwg.org/mailing-list">mailing lists</a>, look through the backlog of mailing list. You can communicate directly <a href="irc://irc.freenode.net/whatwg">using <abbr>IRC</abbr></a> and there&#8217;s even a complete log of all the <a href="http://krijnhoetmer.nl/irc-logs/"><abbr>IRC</abbr> history</a>.  All available from <a href="http://whatwg.org">http://whatwg.org</a>.
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/dd-details-wrong-again/" rel="bookmark" class="crp_title">dd-details wrong again</a></li><li><a href="http://html5doctor.com/its-bug-report-time/" rel="bookmark" class="crp_title">It&#8217;s bug report time!</a></li><li><a href="http://html5doctor.com/html-5-boilerplates/" rel="bookmark" class="crp_title">HTML5 Boilerplates</a></li><li><a href="http://html5doctor.com/html5-doctor-drop-in-clinic/" rel="bookmark" class="crp_title">HTML5 Doctor Drop-In Clinic</a></li><li><a href="http://html5doctor.com/your-questions-18/" rel="bookmark" class="crp_title">Your Questions 18</a></li></ul></div></p>
<p><a href="http://html5doctor.com/2022-or-when-will-html-5-be-ready/" rel="bookmark">2022, or when will HTML 5 be ready?</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 21, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/2022-or-when-will-html-5-be-ready/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>&#8220;Block-level&#8221; links in HTML5</title>
		<link>http://html5doctor.com/block-level-links-in-html-5/</link>
		<comments>http://html5doctor.com/block-level-links-in-html-5/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 12:00:06 +0000</pubDate>
		<dc:creator>Bruce Lawson</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[a]]></category>
		<category><![CDATA[HTML 5]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=455</guid>
		<description><![CDATA[One new and exciting thing you can do in <abbr>HTML</abbr> 5 is wrap links round "block-level" elements. Find out how this works, why it works with true-life sample code.]]></description>
			<content:encoded><![CDATA[<p>One new and exciting thing you can do in <abbr>HTML</abbr> 5 is wrap links round &#8220;block-level&#8221; elements.</p>
<p>Imagine you have a front page with lots of teasers for news articles, each of which leads to a page devoted to the full text of that article. Obviously, each story needs a heading and you&#8217;ll want an image too, and you&#8217;ll want them all clickable. In current mark-up you&#8217;ll probably have something like this:</p>
<pre><code>&lt;div class="story"&gt;
&lt;h3&gt;&lt;a href=&quot;story1.html&quot;&gt;Bruce Lawson voted sexiest man on Earth&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;story1.html&quot;&gt;&lt;img src=&quot;bruce.jpg&quot; alt=&quot;full story. &quot; /&gt;A congress representing all the planet's women unanimously voted Bruce Lawson as sexiest man alive.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;story1.html&quot;&gt;Read more&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</code>
</pre>
<p>Note that you have three identical links (or two if, like the BBC News site, you assume your readers don&#8217;t need a &#8220;read more&#8221; link).</p>
<p>In <abbr>HTML</abbr> 5, you code it like this:</p>
<pre><code>&lt;article&gt;
&lt;a href=&quot;story1.html&quot;&gt;
&lt;h3&gt;Bruce Lawson voted sexiest man on Earth&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;bruce.jpg&quot; alt=&quot;gorgeous lovebundle. &quot;&gt;A congress representing all the planet's women unanimously voted Bruce Lawson as sexiest man alive.&lt;/p&gt;
&lt;p&gt;Read more&lt;/p&gt;
&lt;/a&gt;
&lt;/article&gt;</code></pre>
<p>Now the single link surrounds the whole teaser, removing duplication and creating a much wider hit area to click.</p>
<p>Two points to make about accessibility in passing: firstly, you don&#8217;t need to worry that each &quot;read more&quot; goes to a different destination (see <a href="http://www.w3.org/TR/WCAG20-HTML-TECHS/G53.html"><abbr title="web contant accessibility guidelines">WCAG</abbr> 2</a>) because the whole story is the link, so the link text is unique. Secondly, note that I&#8217;ve changed the alternate text on the image, as in the first instance the image is  a link so I described its destination, whereas the second is just a picture so I describe the image itself&mdash;&#8221;gorgeous lovebundle&#8221;&mdash;and thereby give more information to a screenreader user.</p>
<h2>Shiny, but not new</h2>
<p>What&#8217;s also very interesting about this technique is that  actually this isn&#8217;t new: you can do it now. <abbr>XHTML</abbr> 2 had a similar mechanism, which allowed <code>href</code> on any element  <a href="http://meyerweb.com/eric/thoughts/2008/07/23/any-element-linking-demo/">Eric Meyer called for this to be adopted</a> in <abbr>HTML</abbr> 5 but, of course, this isn&#8217;t backwardly compatible. One of his other solutions to the same problem was changing the rules for <code>a</code>, and <a href="http://www.brucelawson.co.uk/tests/anchors-wrapping-blocks.htm">my test page</a> shows that it works now in all the browsers.</p>
<p>That&#8217;s one of the interesting things about <abbr>HTML</abbr> 5&mdash;it documents existing browser behaviour. As the browsers already handle wrapping links around block-level elements, and there is an obvious use-case, there was no reason to artificially keep the structure as invalid.</p>
<p>(One irony: Eric Meyer&#8217;s original use-case was to link all cells in a table row. This <em>doesn&#8217;t</em> work in <abbr>HTML</abbr> 5; <a href="http://wiki.whatwg.org/wiki/FAQ#HTML5_should_support_href_on_any_element.21">you need script for that</a>.)</p>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul class="related">
<li><a href="http://html5doctor.com/html5-simplequiz-5-urls-of-commenters/" rel="bookmark" class="crp_title">HTML5 Simplequiz 5: URLs of commenters</a></li>
<li><a href="http://html5doctor.com/html5-simplequiz-4-figures-captions-and-alt-text/" rel="bookmark" class="crp_title">HTML5 Simplequiz #4: figures, captions and alt text</a></li>
<li><a href="http://html5doctor.com/draw-attention-with-mark/" rel="bookmark" class="crp_title">Draw attention with mark</a></li>
<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/aside-revisited/" rel="bookmark" class="crp_title">Aside Revisited</a></li>
</ul>
</div>
<p><a href="http://html5doctor.com/block-level-links-in-html-5/" rel="bookmark">&#8220;Block-level&#8221; links in HTML5</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 13, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/block-level-links-in-html-5/feed/</wfw:commentRss>
		<slash:comments>81</slash:comments>
		</item>
	</channel>
</rss>

