<?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; ie</title>
	<atom:link href="http://html5doctor.com/tag/ie/feed/" rel="self" type="application/rss+xml" />
	<link>http://html5doctor.com</link>
	<description>helping you implement HTML5 today</description>
	<lastBuildDate>Tue, 27 Jul 2010 14:36:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Your Questions Answered #7</title>
		<link>http://html5doctor.com/your-questions-answered-7/</link>
		<comments>http://html5doctor.com/your-questions-answered-7/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 14:10:51 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[aside]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[hgroup]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[section]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1584</guid>
		<description><![CDATA[Here we are again with another round up of  patient questions about <abbr>HTML</abbr>5. In this article, we'll be covering a host of topics including <abbr>AJAX</abbr>, the eternal question of <code>div</code> or <code>section</code>, how to markup multiple blocks of content in a sidebar and using <code>header</code> with <code>hgroup</code>.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;source=html5doctor&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Doctor treating a patient illustration" class="alignright size-full wp-image-424" /> Here we are again with another round of patient questions about <abbr>HTML</abbr>5. In this article, we&#8217;ll be covering AJAX, the eternal question of <code>&lt;div&gt;</code> or <code>&lt;section&gt;</code>, our old friend Internet Explorer, how to mark up multiple blocks of content in a sidebar, and using <code>&lt;header&gt;</code> with <code>&lt;hgroup&gt;</code>.</p>
<h2><abbr>HTML</abbr> and AJAX</h2>
<p>Arie asked:</p>
<blockquote><p>I&#8217;m still learning about <abbr>html</abbr>5 and javascript, I&#8217;m wondering how <abbr>html</abbr>5 makes doing a lot of the things currently done in ajax and javascript more simple.  Is it by providing things like the canvas that unify ideas?</p>
</blockquote>
<p>Certain parts of <abbr>HTML</abbr>5 will indeed simplify or reduce the need for JavaScript. One such area of improvement is Web Forms 2.0, which will handle client-side form validation in the browser and provide new input types (like <code>&lt;input type="email"&gt;</code> that checks for a valid email address). Of course, you&#8217;ll still need to validate your forms on the server, but at least the browser will catch the most obvious mistakes before the user actually submits the form.</p>
<p>Other parts of <abbr>HTML</abbr>5, like <a href="http://html5doctor.com/introducing-web-sql-databases/">Web SQL Databases</a> and <code>&lt;canvas&gt;</code>, are essentially JavaScript <abbr>API</abbr>s. They may not cut down on your need for JavaScript, but they do provide a consistent interface to some powerful functionality and will enable your application or site to do more things within (or outside of) the browser.</p>
<p>Cheers, Rich</p>
<h2><code>&lt;div&gt;</code> or <code>&lt;section&gt;</code>?</h2>
<p>Paul asked:</p>
<blockquote><p>Hello</p>
<p>I see you are using divs on your website, I thought divs should be replaced by more semantic tags such as sections or article. what did I miss?</p>
<p>Thanks</p>
</blockquote>
<p>Hi Paul,</p>
<p>Just like with <abbr>HTML</abbr>4, you shouldn&#8217;t use <code>&lt;div&gt;</code>s or <code>&lt;span&gt;</code>s where another, more precise element would fit the bill. But for grouping arbitrary content, <code>&lt;div&gt;</code>s and <code>&lt;span&gt;</code>s remain the way to go.</p>
<p>Thanks, Bruce</p>
<h2><abbr>HTML</abbr>5 and <abbr>IE</abbr>6</h2>
<p>Adam asked:</p>
<blockquote><p>Greetings HTML5 Doctor,</p>
<p>Is it at all possible to have a <abbr>HTML</abbr>5 layout while 30% of our users are running <abbr>IE</abbr>6? We are an <abbr>IT</abbr> company and our website is very large so having separate versions is completely impractical. <abbr>HTML</abbr>5 would allow us to move on and keep our markup a lot simpler but with no concrete guarantees regarding universal support is <abbr>HTML</abbr>5 ever going to get off the ground within 5 years while not having to resort to javascript solutions?</p>
</blockquote>
<p>Simply change the doctype and you&#8217;ll be writing <abbr>HTML</abbr>5! If you want to use new elements, however, you&#8217;ll need to use JavaScript to support them (for all versions of <abbr>IE</abbr> up to <abbr>IE</abbr>8). The best place to start? Read <a href="http://html5doctor.com/author/remys/">Remy&#8217;s</a> article on <a href="http://html5doctor.com/how-to-get-html5-working-in-ie-and-firefox-2/">How to get <abbr>HTML</abbr>5 working in <abbr>IE</abbr> and Firefox 2</a>.</p>
<p>I think we&#8217;re in a position to do something about this. By using the new doctype, block-level links, and new form input types (that degrade gracefully), we can start promoting <abbr>HTML</abbr>5 <em>right now</em>.</p>
<p>Cheers, Rich</p>
<h2>Multiple blocks in a sidebar</h2>
<p>Bart asked:</p>
<blockquote><p>On my page (revora.net) I have a sidebar with content that I deem appropriate for the <code>aside</code> element. The sidebar contains several blocks of content. I&#8217;ve currently made the whole bar <code>aside</code> and made the blocks <code>div</code>. Is this correct, or should I do it the other way around?</p>
</blockquote>
<p>It sounds like your first approach is correct. The <code>&lt;div&gt;</code>s might be <code>&lt;section&gt;</code>s or maybe <code>&lt;nav&gt;</code> elements though, depending on their content. I suggest you read our article (and the comments) on <a href="http://html5doctor.com/aside-revisited/">the <code>&lt;aside&gt;</code> element</a>.</p>
<p>Thanks, Tom</p>
<h2>Header with <code>&lt;hgroup&gt;</code></h2>
<p>Diego asked:</p>
<blockquote><p>Hi,</p>
<p>This structure is right?</p>
<pre><code>&lt;section id="choose-tip"&gt;
   &lt;header&gt;
       &lt;hgroup&gt;
           &lt;h1&gt;Foo Bar&lt;/h1&gt;
           &lt;h2&gt;Baz Bat Qux&lt;/h2&gt;
       &lt;/hgroup&gt;
   &lt;/header&gt;
   &lt;p&gt;lorem ipsum&lt;/p&gt;
&lt;/section&gt;</code></pre>
<p>What I mean is, if I have a HEADER with just 2 H(n) I need to put these into a HGROUP ? Or&#8230; I can remove the HEADER and leave just a HGROUP? What&#8217;s the better solutions for it?</p>
<p>Thanks for all,</p>
<p>Diego Tres</p>
</blockquote>
<p>What you have is correct. Basically, in the document outline, you will only see &#8220;Foo Bar&#8221; as the heading for that section. &#8220;Baz Bat Qux&#8221; will be hidden from the outline.</p>
<p>You don&#8217;t <em>have</em> to use a <code>&lt;header&gt;</code> within your <code>&lt;section&gt;</code> or an <code>&lt;hgroup&gt;</code> within your <code>&lt;header&gt;</code>. Similarly, you don&#8217;t <em>have</em> to use a <code>&lt;header&gt;</code> around your <code>&lt;hgroup&gt;</code>.</p>
<p>To summarise, the best solution (if you don&#8217;t require the <code>&lt;h2&gt;</code> to appear in the document outline) is what you&#8217;ve already got.</p>
<p>Cheers, Rich</p>
<h2>Got a question for us?</h2>
<p>That wraps up this round of questions! If you&#8217;ve got a query about the <abbr>HTML</abbr>5 spec or how to implement it, you can <a href="http://html5doctor.com/ask-the-doctor/">get in touch</a> with us and we&#8217;ll do our best to help.</p>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul>
<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-5/" rel="bookmark" class="crp_title">Your Questions Answered #5</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-6/" rel="bookmark" class="crp_title">Your Questions Answered #6</a></li>
<li><a href="http://html5doctor.com/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>Share and Save:</p>
<p>	<a rel="nofollow"  href="http://twitter.com/home?status=Your%20Questions%20Answered%20%237%20-%20http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F" title="Twitter"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;title=Your%20Questions%20Answered%20%237&amp;bodytext=Here%20we%20are%20again%20with%20another%20round%20up%20of%20%20patient%20questions%20about%20HTML5.%20In%20this%20article%2C%20we%27ll%20be%20covering%20a%20host%20of%20topics%20including%20AJAX%2C%20the%20eternal%20question%20of%20div%20or%20section%2C%20how%20to%20markup%20multiple%20blocks%20of%20content%20in%20a%20sidebar%20and%20using%20header%20with%20hgroup." title="Digg"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F" title="Sphinn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;title=Your%20Questions%20Answered%20%237" title="Reddit"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;title=Your%20Questions%20Answered%20%237&amp;notes=Here%20we%20are%20again%20with%20another%20round%20up%20of%20%20patient%20questions%20about%20HTML5.%20In%20this%20article%2C%20we%27ll%20be%20covering%20a%20host%20of%20topics%20including%20AJAX%2C%20the%20eternal%20question%20of%20div%20or%20section%2C%20how%20to%20markup%20multiple%20blocks%20of%20content%20in%20a%20sidebar%20and%20using%20header%20with%20hgroup." title="del.icio.us"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;title=Your%20Questions%20Answered%20%237" title="StumbleUpon"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F" title="Technorati"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Your%20Questions%20Answered%20%237&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F" title="Netvibes"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;t=Your%20Questions%20Answered%20%237" title="Facebook"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;title=Your%20Questions%20Answered%20%237&amp;annotation=Here%20we%20are%20again%20with%20another%20round%20up%20of%20%20patient%20questions%20about%20HTML5.%20In%20this%20article%2C%20we%27ll%20be%20covering%20a%20host%20of%20topics%20including%20AJAX%2C%20the%20eternal%20question%20of%20div%20or%20section%2C%20how%20to%20markup%20multiple%20blocks%20of%20content%20in%20a%20sidebar%20and%20using%20header%20with%20hgroup." title="Google Bookmarks"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Your%20Questions%20Answered%20%237&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F" title="FriendFeed"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;t=Your%20Questions%20Answered%20%237" title="HackerNews"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;title=Your%20Questions%20Answered%20%237&amp;source=HTML5+Doctor+helping+you+implement+HTML5+today&amp;summary=Here%20we%20are%20again%20with%20another%20round%20up%20of%20%20patient%20questions%20about%20HTML5.%20In%20this%20article%2C%20we%27ll%20be%20covering%20a%20host%20of%20topics%20including%20AJAX%2C%20the%20eternal%20question%20of%20div%20or%20section%2C%20how%20to%20markup%20multiple%20blocks%20of%20content%20in%20a%20sidebar%20and%20using%20header%20with%20hgroup." title="LinkedIn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;h=Your%20Questions%20Answered%20%237" title="NewsVine"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml5doctor.com%2Fyour-questions-answered-7%2F&amp;t=Your%20Questions%20Answered%20%237&amp;s=Here%20we%20are%20again%20with%20another%20round%20up%20of%20%20patient%20questions%20about%20HTML5.%20In%20this%20article%2C%20we%27ll%20be%20covering%20a%20host%20of%20topics%20including%20AJAX%2C%20the%20eternal%20question%20of%20div%20or%20section%2C%20how%20to%20markup%20multiple%20blocks%20of%20content%20in%20a%20sidebar%20and%20using%20header%20with%20hgroup." title="Tumblr"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
<p><a href="http://html5doctor.com/your-questions-answered-7/" rel="bookmark">Your Questions Answered #7</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on April 20, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-answered-7/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>dd-details wrong again</title>
		<link>http://html5doctor.com/dd-details-wrong-again/</link>
		<comments>http://html5doctor.com/dd-details-wrong-again/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 12:00:57 +0000</pubDate>
		<dc:creator>Remy Sharp</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[details]]></category>
		<category><![CDATA[dt]]></category>
		<category><![CDATA[figure]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=991</guid>
		<description><![CDATA[
            
                
            
        You may recall that I blogged about [...]]]></description>
			<content:encoded><![CDATA[<p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
            <a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F">
                <img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;source=html5doctor&amp;style=normal&amp;service=is.gd" height="61" width="50" />
            </a>
        </div>You may recall that I blogged about <a href="http://html5doctor.com/legend-not-such-a-legend-anymore/">legend not being so legend</a> as the heading element for <code>details</code> or <code>figure</code>. After enough noise was made the spec was changed so that the heading and contents of these elements can now be marked up using the <code>dt/dd</code> combo.</p>

<p>Although not immediately obvious why it&#8217;s the right choice, it appeared to work for our needs&#8230;at first. Of course now, it&#8217;s been discovered that it&#8217;s actually a pretty bad idea.</p>

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

<h2>How we got here</h2>

<p>In short, <code>details</code> and <code>figure</code> solve a common design pattern and provide nice new semantic tags to solve that problem.  A <code>figure</code> could be an image you&#8217;re referring to in an article or chapter of a book, and the <code>details</code> element allows the user to interactively show and hide the <em>details</em> of some piece of information.</p>

<p>Both elements can contain a heading element to label up the contents.  For some reason, beyond this author&#8217;s understanding, these two elements, completely different in meaning, have been historically tied to using the same solution solve the problem how to markup the heading.</p>

<p>As I mentioned earlier, originally the proposed solution for the headings was to use the <code>legend</code> element, which <a href="http://html5doctor.com/legend-not-such-a-legend-anymore/">proved to completely break</a> in every browser (in new and interesting ways).</p>

<p>Skip forward to mid-September, and Jeremy Keith <a href="http://lists.w3.org/Archives/Public/public-html/2009Sep/0534.html">proposes that we solve the legend issue</a> with the dt/dd combo, and Ian Hickson <a href="http://lists.w3.org/Archives/Public/public-html/2009Sep/0566.html">says</a>:</p>

<blockquote>
  <p>That&#8217;s not a bad idea actually. Ok, done.</p>
</blockquote>

<p>Before this was proposed there was lots of discussion about why we couldn&#8217;t introduce a new element to solve this problem, and Ian points out already 18 (or 22, I forget!) elements that represent some sort of heading.  This is the argument for not introducing another new heading type element to solve the <code>details</code> and <code>figure</code> problem.</p>

<h2>The problem with dt/dd</h2>

<p>Ironically the problem <em>isn&#8217;t</em> with the <code>dt</code> part of the solution, it&#8217;s actually with the <code>dd</code>.  </p>

<p><a href="http://dean.edwards.name/" title="dean.edwards.name/">Dean Edwards</a> (genius behind some very cool JavaScript and something that will soon blow your minds) has been testing these elements in <em>detail</em> and found a very serious issue with the <code>dd</code> in, guess what, IE6 &#038; 7.  I want to explain and draw attention to what Dean has found.</p>

<p>Styling a <code>dd</code> within <code>details</code> or <code>figure</code> (and probably other elements) bleeds to the next element.</p>

<p>By styling a dd red, and only the dd, here&#8217;s what it <em>should</em> look like (and does in IE8):</p>

<p><img src="http://html5doctor.com/wp-content/uploads/2009/10/dd-ie8.png" alt="dd styled in IE8" /></p>

<p>Where as in IE7 (and IE6), the red style bleeds in to the following <code>p</code> element (note the &#8220;this paragraph shouldn&#8217;t be red&#8221;):</p>

<p>![dd styled in IE7](<img src="http://html5doctor.com/wp-content/uploads/2009/10/dd-ie7.png" alt="dd styled in IE8" /></p>

<p>What&#8217;s more, if you look back at the screen shots you can see the last paragraph says &#8220;Contents of first &lt;dd&gt;&#8221;.  The result of that test is being generated by the following JavaScript:</p>

<pre><code>document.getElementsByTagName('dd')[0].innerHTML</code></pre>

<p>Notice how in IE7, the contents of the first <code>dd</code>&#8217;s <code>innerHTML</code> is <strong>empty</strong>.</p>

<p>The problem here is that:</p>

<ol>
<li>IE7 and below can&#8217;t style a <code>dd</code> properly without it breaking and the style bleeding in to adjacent elements.</li>
<li>JavaScript, randomly, can&#8217;t see the contents of the <code>dd</code>.</li>
</ol>

<h2>Is there hope?</h2>

<p>There is a hack that fixes this issue. It&#8217;s pretty mad, but it does fix the styling issue. However the side effects from this hack are outright unacceptable and are so serious I would argue that the hack solution itself is a bug.</p>

<p>The hack is over at the <a href="http://lists.w3.org/Archives/Public/public-html/2009Sep/0802.html">public-html of W3.org</a>, and involves stuffing an open <code>object</code> tag just before we close the <code>head</code> tag.</p>

<p>This isn&#8217;t a clean solution for including in HTML by hand, authors won&#8217;t remember or might get it wrong, so it needs to be perhaps automated as part of the HTML5 enabling script, right?  It would have to be inserted using <code>document.write()</code> as the last part of the <code>head</code> element.</p>

<p>Dean went on to test this, and <a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-September/023247.html">he found</a>:</p>

<blockquote>
  <p>There is a nasty side effect though. As you mentioned the document.write() should be the last thing in the &lt;head&gt;. If there are any scripts following the document.write() then they are <em>not executed</em>.</p>
</blockquote>

<p>The <em>really</em> freakin&#8217; important bit:</p>

<blockquote>
  <p>If there are any scripts following the document.write() then they are <em>not executed</em></p>
</blockquote>

<p>So, to answer the question: <em>is there hope?</em> No, not for the dd/dt combo.  It can&#8217;t be styled properly and hacks will break JavaScript.</p>

<h2>We want the details</h2>

<p>We, as authors, want to make use of <code>details</code> and <code>figure</code> today. Waiting for IE7 to fall out of circulation before we start using these elements (as it&#8217;s been proposed a number of times on the IRC channel and mailing boards) is outright not going to happen.  IE6 &#038; 7 are going to be around for a good more number of years, certainly IE7 (IE6 has at least another 5 years in the beast).</p>

<p>We <em>are</em> going to start enabling the <code>details</code> interactive UI pattern using JavaScript whilst we wait for vendors bake it in to the browser, so the final proposed markup needs to work in all the browsers, <em>including</em> IE6 and IE7.</p>

<p>What are our current options?</p>

<ol>
<li>Give new meaning to an existing element (as we&#8217;ve already tried to), <code>legend</code>, <code>label</code> and <code>dt/dd</code> have been tried, tested and failed. What else could we use?</li>
<li>Repurpose one of the existing <em>new</em> elements (keeping in mind that the dt/dd was repurposed so it should be a consideration).</li>
<li>Create <em>another</em> heading element to solve this problem.</li>
</ol>

<p>The problem is that the conversation seems to have lost steam (or certain Dean was starting to see the conversation go in circles).  If you want to see these two elements make it the final spec, and correctly, head over to either the <a href="irc://irc.freenode.net/#whatwg">IRC channel</a> or the <a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/">mailing list</a>, and get heard.</p>

<h2>Reference links</h2>

<ul>
<li><a href="http://dean.edwards.name/test/details.html">Dean&#8217;s original details test</a> (my modified tests to fire the innerHTML on load: <a href="http://jsbin.com/inugi/edit#html">details</a>, <a href="http://jsbin.com/uluro/edit#html">figure</a>)</li>
<li>Litmusapp browser screenshots of the results: <a href="http://leftlogic.litmusapp.com/pub/6bee14e">details</a>, <a href="http://leftlogic.litmusapp.com/pub/c7f18b4">figure</a></li>
<li>whatwg mailing list thread: <a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-September/023240.html">September</a>, <a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-October/023277.html">October</a><div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://html5doctor.com/legend-not-such-a-legend-anymore/" rel="bookmark" class="crp_title">Legend not such a legend anymore</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/how-to-get-html5-working-in-ie-and-firefox-2/" rel="bookmark" class="crp_title">How to get HTML5 working in IE and Firefox 2</a></li><li><a href="http://html5doctor.com/2022-or-when-will-html-5-be-ready/" rel="bookmark" class="crp_title">2022, or when will HTML 5 be ready?</a></li><li><a href="http://html5doctor.com/september-html5-spec-changes/" rel="bookmark" class="crp_title">September HTML5 spec changes</a></li></ul></div></li>
</ul>

<p>Share and Save:</p>

<pre><code>&lt;a rel="nofollow"  href="http://twitter.com/home?status=dd-details%20wrong%20again%20-%20http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F" title="Twitter"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;title=dd-details%20wrong%20again&amp;amp;bodytext=You%20may%20recall%20that%20I%20blogged%20about%20%5Blegend%20not%20being%20so%20legend%5D%28http%3A%2F%2Fhtml5doctor.com%2Flegend-not-such-a-legend-anymore%2F%29%20as%20the%20heading%20element%20for%20details%20or%20figure.%20After%20enough%20noise%20was%20made%20the%20spec%20was%20changed%20so%20that%20the%20heading%20and%20contents" title="Digg"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;amp;m=submit&amp;amp;link=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F" title="Sphinn"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;title=dd-details%20wrong%20again" title="Reddit"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;title=dd-details%20wrong%20again&amp;amp;notes=You%20may%20recall%20that%20I%20blogged%20about%20%5Blegend%20not%20being%20so%20legend%5D%28http%3A%2F%2Fhtml5doctor.com%2Flegend-not-such-a-legend-anymore%2F%29%20as%20the%20heading%20element%20for%20details%20or%20figure.%20After%20enough%20noise%20was%20made%20the%20spec%20was%20changed%20so%20that%20the%20heading%20and%20contents" title="del.icio.us"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;title=dd-details%20wrong%20again" title="StumbleUpon"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F" title="Technorati"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.netvibes.com/share?title=dd-details%20wrong%20again&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F" title="Netvibes"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;t=dd-details%20wrong%20again" title="Facebook"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;title=dd-details%20wrong%20again&amp;amp;annotation=You%20may%20recall%20that%20I%20blogged%20about%20%5Blegend%20not%20being%20so%20legend%5D%28http%3A%2F%2Fhtml5doctor.com%2Flegend-not-such-a-legend-anymore%2F%29%20as%20the%20heading%20element%20for%20details%20or%20figure.%20After%20enough%20noise%20was%20made%20the%20spec%20was%20changed%20so%20that%20the%20heading%20and%20contents" title="Google Bookmarks"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.friendfeed.com/share?title=dd-details%20wrong%20again&amp;amp;link=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F" title="FriendFeed"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;t=dd-details%20wrong%20again" title="HackerNews"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;title=dd-details%20wrong%20again&amp;amp;source=HTML5+Doctor+helping+you+implement+HTML5+today&amp;amp;summary=You%20may%20recall%20that%20I%20blogged%20about%20%5Blegend%20not%20being%20so%20legend%5D%28http%3A%2F%2Fhtml5doctor.com%2Flegend-not-such-a-legend-anymore%2F%29%20as%20the%20heading%20element%20for%20details%20or%20figure.%20After%20enough%20noise%20was%20made%20the%20spec%20was%20changed%20so%20that%20the%20heading%20and%20contents" title="LinkedIn"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.newsvine.com/_tools/seed&amp;amp;save?u=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;h=dd-details%20wrong%20again" title="NewsVine"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;amp;u=http%3A%2F%2Fhtml5doctor.com%2Fdd-details-wrong-again%2F&amp;amp;t=dd-details%20wrong%20again&amp;amp;s=You%20may%20recall%20that%20I%20blogged%20about%20%5Blegend%20not%20being%20so%20legend%5D%28http%3A%2F%2Fhtml5doctor.com%2Flegend-not-such-a-legend-anymore%2F%29%20as%20the%20heading%20element%20for%20details%20or%20figure.%20After%20enough%20noise%20was%20made%20the%20spec%20was%20changed%20so%20that%20the%20heading%20and%20contents" title="Tumblr"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /&gt;&lt;/a&gt;
</code></pre>

<p>&lt;br/>&lt;br/></p>
<p><a href="http://html5doctor.com/dd-details-wrong-again/" rel="bookmark">dd-details wrong again</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 12, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/dd-details-wrong-again/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>How to get HTML5 working in IE and Firefox 2</title>
		<link>http://html5doctor.com/how-to-get-html5-working-in-ie-and-firefox-2/</link>
		<comments>http://html5doctor.com/how-to-get-html5-working-in-ie-and-firefox-2/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 08:05:45 +0000</pubDate>
		<dc:creator>Remy Sharp</dc:creator>
				<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Structure]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=134</guid>
		<description><![CDATA[
			
				
			
		HTML 5 may be the latest and greatest technology, but some browsers don&#8217;t have native support for the new semantic elements. Let&#8217;s momentarily forget about the really sexy functionality, like full control over the &#60;video&#62; element, and just focus on getting the elements rendered.

The problematic A-grade browsers include IE 8 and below, Firefox 2, and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;source=html5doctor&amp;style=normal&amp;service=is.gd" height="61" width="50" />
			</a>
		</div><p><abbr>HTML</abbr> 5 may be the latest and greatest technology, but <em>some</em> browsers don&#8217;t have native support for the new semantic elements. Let&#8217;s momentarily forget about the really sexy functionality, like <a href="http://html5doctor.com/the-video-element/">full control over the <code>&lt;video&gt;</code> element</a>, and just focus on getting the elements rendered.</p>

<p>The problematic <a href="http://developer.yahoo.com/yui/articles/gbs/">A-grade browsers</a> include <abbr>IE</abbr> 8 and below, Firefox 2, and Camino 1 (these last two browsers both use the Gecko rendering engine, which is why they&#8217;re both affected).</p>

<p>Let&#8217;s start with Internet Explorer.</p>

<span id="more-134"></span>

<h2><abbr>IE</abbr> doesn&#8217;t believe in <abbr>HTML</abbr> 5 elements</h2>

<p>Quite simply, <abbr>IE</abbr> doesn&#8217;t even <em>see</em> <abbr>HTML</abbr> 5 elements, much less style them.</p>

<p>This is actually the same issue that we had before <abbr>HTML</abbr> 5, where the <code>&lt;abbr&gt;</code> element couldn&#8217;t be styled in <abbr>IE</abbr> 6, resulting in <a href="http://www.sovavsiti.cz/css/abbr.html">all manner</a> of <a href="http://dean.edwards.name/my/abbr-cadabra.html">workarounds</a>. (Let me add that we&#8217;ll also fix the <code>&lt;abbr&gt;</code> element while we convince <abbr>IE</abbr> to recognise <abbr>HTML</abbr> 5 elements).</p>

<h3>The fix</h3>

<p>There is hope! The trick, discovered by <a href="http://intertwingly.net/blog/2008/01/22/Best-Standards-Support#c1201006277">Sjoerd Visscher</a>, is simply to create the new element using JavaScript, and <em lang="fr">voilà</em>, <abbr>IE</abbr> is able to style it:</p>

<pre><code>document.createElement('header');</code></pre>

<p>John Resig has also written about this <a href="http://ejohn.org/blog/html5-shiv/"><abbr>HTML</abbr> 5 shiv</a>.</p>

<p>For example, say you wanted to style the <code>&lt;time&gt;</code> element in italics:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;Header test&lt;/title&gt;
  &lt;style&gt;
  time { font-style: italic; }
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;time datetime=&quot;2009-09-13&quot;&gt;my birthday&lt;/time&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>

<p>This screenshot shows the rendering in <abbr>IE</abbr> <a href="http://jsbin.com/urawa">before</a> we apply the fix:</p>

<p><img class="alignnone size-full wp-image-143" title="IE without HTML 5 shiv" src="http://html5doctor.com/wp-content/uploads/2009/06/ie-without.png" alt="IE without HTML 5 shiv" width="570" height="337" /></p>

<p>To apply the fix, add the indicated line of code:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;Header test&lt;/title&gt;
  &lt;style&gt;
  time { font-style: italic; }
  &lt;/style&gt;
  
  &lt;!-- Add this line --&gt;
  &lt;script&gt;document.createElement('time');&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;time datetime=&quot;2009-09-13&quot;&gt;my birthday&lt;/time&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>

<p>Now <a href="http://jsbin.com/iduto">after</a> we&#8217;ve applied the fix, it&#8217;s correctly styled in <abbr>IE</abbr>:</p>

<p><img class="alignnone size-full wp-image-142" title="IE with HTML 5 shiv" src="http://html5doctor.com/wp-content/uploads/2009/06/ie-with.png" alt="IE with HTML 5 shiv" width="565" height="327" /></p>

<h3>One hit solution</h3>

<p>For everyone&#8217;s convenience, I wrote a single JavaScript file that can be included to create all the <abbr>HTML</abbr> 5 elements (and the <code>&lt;abbr&gt;</code> element) for <abbr>IE</abbr>.</p>

<p><a href="http://remysharp.com/downloads/html5.js">Download the <abbr>IE</abbr> <abbr>HTML</abbr> 5 enabling script</a></p>

<p>Include the script in your <code>&lt;head&gt;</code> tag, and you&#8217;ll be able to style the elements appropriately in <abbr>IE</abbr>:</p>

<pre><code>&lt;!--[if lte IE 8]&gt;
&lt;script src=&quot;html5.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;![endif]--&gt;</code></pre>

<p>Note that I&#8217;ve used a conditional comment to only apply this to <abbr>IE</abbr> 8 and below. It&#8217;s my hope that <abbr>IE</abbr> 9 and onwards will support <abbr>HTML</abbr> 5 elements, but when that day comes, make sure to double check the conditional!</p>

<h3>Conditions &amp; Gotchas</h3>

<p>There are a couple of things to be aware of when using the HTML 5 shiv.</p>

<h4>JavaScript required</h4>

<p>This obviously means that your design now depends on JavaScript. Personally, I feel that if you&#8217;ve used semantic markup for your site and the elements can&#8217;t be styled, the content is still completely readable.</p>

<p>Here&#8217;s a screenshot of the <a href="http://2009.full-frontal.org/">Full Frontal</a> web site, written using <abbr>HTML</abbr> 5 elements, rendered in <abbr>IE</abbr> with and without JavaScript enabled:</p>

<p><img class="alignnone size-full wp-image-141" title="IE with and without JavaScript to fix HTML 5" src="http://html5doctor.com/wp-content/uploads/2009/06/ie-js-fix-compare.png" alt="IE with and without JavaScript to fix HTML 5" width="600" height="304" /></p>

<p>You can see in the second screenshot that the content isn&#8217;t perfect, but it&#8217;s still readable &mdash; it cascades down correctly, much as if <abbr>CSS</abbr> were disabled.</p>

<h4 id="a-little-head">A little head is always good</h4>

<p>If you create the new element and <em>don&#8217;t</em> use a <code>&lt;body&gt;</code> tag (which is perfectly valid <abbr>HTML</abbr> 5), <abbr>IE</abbr> will put all those created elements inside the <code>&lt;head&gt;</code> tag. Pretty crazy, but you can easily avoid this by always using both the <code>&lt;head&gt;</code> and <code>&lt;body&gt;</code> tags in your markup. <a href="http://blog.whatwg.org/supporting-new-elements-in-ie#comment-40743">Leif Halvard explains further with demos.</a></p>

<h2>Firefox 2 and Camino 1 rendering bug</h2>

<p>Both Firefox 2 and Camino 1 have a bug in the Gecko rendering engine (specifically versions prior to 1.9b5):</p>

<blockquote><p>Firefox 2 (or any other Gecko-based browser with a Gecko version pre 1.9b5) has a parsing bug where it will close an unknown element when it sees the start tag of a &#8220;block&#8221; element p, h1, div, and so forth.</p></blockquote>

<p>According to the <a href="http://www.w3schools.com/browsers/browsers_firefox.asp">W3 Schools stats</a>, Firefox 2 only has around 3% of the market &mdash; perhaps low enough to justify ignoring it. It&#8217;s safe to assume that Camino 1 commands an even smaller percentage of the market.</p>

<p>By ignoring this issue, however, a site can look quite bad in these browsers. So how can we fix it?</p>

<p>The bug surfaces when Gecko doesn&#8217;t recognise an element. Explained roughly, when Gecko parses an unrecognised element, it removes the element&#8217;s contents and puts them next to the element.</p>

<p>Take, for example, the following code:</p>

<pre><code>&lt;body&gt;
  &lt;header&gt;&lt;h1&gt;Title&lt;/h1&gt;&lt;/header&gt;
  &lt;article&gt;&lt;p&gt;...&lt;/p&gt;&lt;/article&gt;
&lt;/body&gt;</pre></code>

<p>This will be parsed in Gecko (prior to version 1.9b5) as if the markup were actually as follows:</p>

<pre><code>&lt;body&gt;
  &lt;header&gt;&lt;/header&gt;
  &lt;h1&gt;Title&lt;/h1&gt;
  &lt;article&gt;&lt;/article&gt;
  &lt;p&gt;...&lt;/p&gt;
&lt;/body&gt;</code></pre>

<p>The visual result is similar to the above screenshot of <abbr>IE</abbr> running without JavaScript (though subtly different, as the DOM tree is actually in a different order than you as the author intended).</p>

<h3>The fix</h3>

<p>There are two approaches to fixing this issue, and so far I've only successfully used the non-JavaScript approach.</p>

<h4>The JavaScript solution</h4>

<p>The first approach is to use JavaScript to traverse the DOM tree, rearranging elements as issues are encountered. Simon Pieters has a <a href="http://blog.whatwg.org/supporting-new-elements-in-firefox-2">small working example</a> of how this can be done (towards the bottom of the page). In practise, however, I <em>personally</em> found it didn't work for my markup. The problem is definitely solvable using JavaScript, but this solution still needs work to handle all permutations of markup.</p>

<h4>The <abbr>XHTML</abbr> solution</h4>

<p>The second approach is to serve Gecko XHTML. I've found this to be the easier approach if you're either generating a page dynamically (using something like PHP) or if you can create your own <code>.htaccess</code> file to use Apache's <code>mod_rewrite</code>.</p>

<p>The first change to your markup is to add the <code>xmlns</code> attribute to your <code>&lt;html&gt;</code> tag:</p>

<pre><code>&lt;html lang=&quot;en&quot; xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;</code></pre>

<p>Next, we need to sniff the user agent string (typically a bad approach, but justifiable when targeting such a specific group of users). If the Gecko build is less than 1.9, then we need to set the Content-type header to <code>application/xhtml+xml</code>.</p>

<p>If you want to use <code>mod_rewrite</code> in an <code>.htaccess</code> file (or the <code>httpd.conf</code> file), you need the following rules:</p>

<pre><code>RewriteCond %{REQUEST_URI} \.html$
RewriteCond %{HTTP_USER_AGENT} rv:1\.(([1-8]|9pre|9a|9b[0-4])\.[0-9.]+).*Gecko
RewriteRule .* - [T=application/xhtml+xml]</code></pre>

<p>This rule sends the proper Content-type header to all Gecko based browsers where version is less than 1.9, or "rv:1.9pre" or "rv:1.9a" or "rv:1.9b<em>x</em>" where <em>x</em> is less than 5.</p>

<p>If you don't want to use the <code>mod_rewrite</code> approach, you'll need to manually send the header in your server side scripts. Here's a solution for a PHP script:</p>

<pre><code>if (preg_match('/rv:1\.(([1-8]|9pre|9a|9b[0-4])\.[0-9.]+).*Gecko/', $_SERVER['HTTP_USER_AGENT'])) {
  header('Content-type: application/xhtml+xml');
}</code></pre>

<p>This snippet needs to be included <em>before</em> anything has been printed by your script &mdash; i.e., as early as possible.</p>

<h3>Gotcha: Yellow Screen of Death</h3>

<p>The Yellow Screen of Death shows up whenever there's an <abbr>XML</abbr> error on the page. If we're serving markup as <abbr>XML</abbr> and telling the browser to interpret it strictly as <abbr>XML</abbr>, then we can't serve any characters it doesn't recognise or else it's going to bork:</p>

<p><img src="http://upload.wikimedia.org/wikipedia/commons/4/48/Yellow_screen_of_death.png" alt="Yellow Screen of Death" /></p>

<p>Below are a few ways to avoid <abbr>XML</abbr> parsing errors.</p>

<h4>Create strict markup</h4>

<p>You need to ensure your markup is squeaky clean &mdash; but that's easy, because you're already a Markup Jedi, right?</p>

<h4>Use <abbr>XML</abbr> entities</h4>

<p><abbr>HTML</abbr> entities are a no-no. Sorry, but <code>&amp;bull;</code> isn't going to fly anymore. You need to use <abbr>XML</abbr> entities, the numerical representation of these characters.</p>

<p>I've built <a href="http://leftlogic.com/lounge/articles/entity-lookup/">an entity lookup tool</a> that shows the <abbr>HTML</abbr> entity and the <abbr>XML</abbr> value of that entity. For example, <code>&amp;bull;</code> is 8226, so the XML entity is <code>&amp;#8226;</code>.</p>

<h4>Sanitise user generated content</h4>

<p>If your site relies on any user generated content (e.g., blog comments), then you need to sanitise the output to ensure there are no validation issues to trigger the Yellow Screen of Death.</p>

<p>This issue alone may justify further investigation of a JavaScript solution.</p>

<h3>Worth the trouble?</h3>

<p>All that said, Firefox has a very good automated upgrade path. Looking at the <a href="http://www.w3schools.com/browsers/browsers_firefox.asp">stats on W3Schools</a>, it's safe to say that the number of users with this Gecko bug is rapidly diminishing.</p>

<h2>Further reading</h2>

<ul>
<li><a href="http://blog.whatwg.org/supporting-new-elements-in-firefox-2">Firefox 2 rendering issue on WHATWG Blog</a></li>
<li><a href="http://blog.whatwg.org/supporting-new-elements-in-ie#comment-40743"><abbr>IE</abbr> / missing head tag issue</a></li>
<li><a href="http://ejohn.org/blog/html5-shiv/"><abbr>HTML</abbr> 5 shiv</a></li>
<li><a href="http://remysharp.com/2009/01/07/html5-enabling-script/"><abbr>HTML</abbr> 5 enabling script</a></li>
</ul>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://html5doctor.com/html-5-boilerplates/" rel="bookmark" class="crp_title">HTML5 Boilerplates</a></li><li><a href="http://html5doctor.com/legend-not-such-a-legend-anymore/" rel="bookmark" class="crp_title">Legend not such a legend anymore</a></li><li><a href="http://html5doctor.com/dd-details-wrong-again/" rel="bookmark" class="crp_title">dd-details wrong again</a></li><li><a href="http://html5doctor.com/native-drag-and-drop/" rel="bookmark" class="crp_title">Native Drag and Drop</a></li><li><a href="http://html5doctor.com/designing-a-blog-with-html5/" rel="bookmark" class="crp_title">Designing a blog with html5</a></li></ul></div>


Share and Save:


	<a rel="nofollow"  href="http://twitter.com/home?status=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202%20-%20http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F" title="Twitter"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;title=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202&amp;bodytext=HTML%205%20may%20be%20the%20latest%20and%20greatest%20technology%2C%20but%20some%20browsers%20don%27t%20have%20native%20support%20for%20the%20new%20semantic%20elements.%20Let%27s%20momentarily%20forget%20about%20the%20really%20sexy%20functionality%2C%20like%20full%20control%20over%20the%20%26lt%3Bvideo%26gt%3B%20element%2C%20and%20just%20focu" title="Digg"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F" title="Sphinn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;title=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202" title="Reddit"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;title=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202&amp;notes=HTML%205%20may%20be%20the%20latest%20and%20greatest%20technology%2C%20but%20some%20browsers%20don%27t%20have%20native%20support%20for%20the%20new%20semantic%20elements.%20Let%27s%20momentarily%20forget%20about%20the%20really%20sexy%20functionality%2C%20like%20full%20control%20over%20the%20%26lt%3Bvideo%26gt%3B%20element%2C%20and%20just%20focu" title="del.icio.us"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;title=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202" title="StumbleUpon"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F" title="Technorati"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F" title="Netvibes"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;t=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202" title="Facebook"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;title=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202&amp;annotation=HTML%205%20may%20be%20the%20latest%20and%20greatest%20technology%2C%20but%20some%20browsers%20don%27t%20have%20native%20support%20for%20the%20new%20semantic%20elements.%20Let%27s%20momentarily%20forget%20about%20the%20really%20sexy%20functionality%2C%20like%20full%20control%20over%20the%20%26lt%3Bvideo%26gt%3B%20element%2C%20and%20just%20focu" title="Google Bookmarks"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F" title="FriendFeed"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;t=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202" title="HackerNews"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;title=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202&amp;source=HTML5+Doctor+helping+you+implement+HTML5+today&amp;summary=HTML%205%20may%20be%20the%20latest%20and%20greatest%20technology%2C%20but%20some%20browsers%20don%27t%20have%20native%20support%20for%20the%20new%20semantic%20elements.%20Let%27s%20momentarily%20forget%20about%20the%20really%20sexy%20functionality%2C%20like%20full%20control%20over%20the%20%26lt%3Bvideo%26gt%3B%20element%2C%20and%20just%20focu" title="LinkedIn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;h=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202" title="NewsVine"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml5doctor.com%2Fhow-to-get-html5-working-in-ie-and-firefox-2%2F&amp;t=How%20to%20get%20HTML5%20working%20in%20IE%20and%20Firefox%202&amp;s=HTML%205%20may%20be%20the%20latest%20and%20greatest%20technology%2C%20but%20some%20browsers%20don%27t%20have%20native%20support%20for%20the%20new%20semantic%20elements.%20Let%27s%20momentarily%20forget%20about%20the%20really%20sexy%20functionality%2C%20like%20full%20control%20over%20the%20%26lt%3Bvideo%26gt%3B%20element%2C%20and%20just%20focu" title="Tumblr"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a>


<br/><br/><p><a href="http://html5doctor.com/how-to-get-html5-working-in-ie-and-firefox-2/" rel="bookmark">How to get HTML5 working in IE and Firefox 2</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on June 20, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/how-to-get-html5-working-in-ie-and-firefox-2/feed/</wfw:commentRss>
		<slash:comments>95</slash:comments>
		</item>
	</channel>
</rss>
