<?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>Mozilla Hacks - the Web developer blog &#187; Standards</title>
	<atom:link href="http://hacks.mozilla.org/category/standards/feed/" rel="self" type="application/rss+xml" />
	<link>http://hacks.mozilla.org</link>
	<description>hacks.mozilla.org</description>
	<lastBuildDate>Wed, 08 Feb 2012 22:52:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CSS 3D transformations in Firefox Nightly</title>
		<link>http://hacks.mozilla.org/2011/10/css-3d-transformations-in-firefox-nightly/</link>
		<comments>http://hacks.mozilla.org/2011/10/css-3d-transformations-in-firefox-nightly/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 20:18:42 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Feature]]></category>
		<category><![CDATA[Featured Demo]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Developers]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=10017</guid>
		<description><![CDATA[When the first 3D transformations in CSS got support on Webkit browsers people got incredibly excited about them. Now that they have matured we also support 3D CSS in Firefox. To see it for yourself, check out one of the latest nightly builds. You can see them in action in this demo of a rotating [...]]]></description>
			<content:encoded><![CDATA[<p>When the first 3D transformations in CSS got support on Webkit browsers people got incredibly excited about them. Now <a href="http://dev.w3.org/csswg/css3-3d-transforms/">that they have matured</a> we also support 3D CSS in Firefox. To see it for yourself, check out <a href="http://nightly.mozilla.org">one of the latest nightly builds</a>. </p>
<p>You can see them in action in <a href="http://thewebrocks.com/demos/html5-3d-css">this demo of a rotating HTML5 logo</a> and the screencast below:</p>
<p><video controls preload="none" style="width:100%;height:300px;" poster="http://cf.cdn.vid.ly/5l3j6a/poster.jpg"><source src="http://cf.cdn.vid.ly/5l3j6a/mp4.mp4" type="video/mp4"><source src="http://cf.cdn.vid.ly/5l3j6a/webm.webm" type="video/webm"><source src="http://cf.cdn.vid.ly/5l3j6a/ogv.ogv" type="video/ogg"><a target='_blank' href='http://vid.ly/5l3j6a'><img   src='http://cf.cdn.vid.ly/5l3j6a/poster.jpg' width="500"></a></video></p>
<p>This means now that we need your support in trying out CSS 3D examples in Firefox and add other extensions than <code>-webkit-</code> to your CSS 3D products and demos. To show that this is possible, we took the well-known <a href="http://www.webkit.org/blog-files/3d-transforms/poster-circle.html">webkit-only &#8220;poster circle&#8221; demo</a> and made it work with Firefox nightly by adding the -moz- (and of course the other prefixes and one set of instructions without browser prefixes). Here is a slight excerpt:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">-webkit-transform-style<span style="color: #00AA00;">:</span> preserve-3d<span style="color: #00AA00;">;</span>
-moz-transform-style<span style="color: #00AA00;">:</span> preserve-3d<span style="color: #00AA00;">;</span>
-o-transform-style<span style="color: #00AA00;">:</span> preserve-3d<span style="color: #00AA00;">;</span>
-ms-transform-style<span style="color: #00AA00;">:</span> preserve-3d<span style="color: #00AA00;">;</span>
transform-style<span style="color: #00AA00;">:</span> preserve-3d<span style="color: #00AA00;">;</span></pre></div></div>

<p>You can see this in action in the screencast below alongside Chrome and you <a href="http://thewebrocks.com/demos/postercircle/">try the demo out yourself</a>. The slight jerkiness is actually my MacBook Air impersonating a starting jet every time I use ScreenFlow and not the browser.</p>
<p><video controls preload="none" style="width:100%;height:300px;" poster="http://cf.cdn.vid.ly/4m8d9f/poster.jpg"><source src="http://cf.cdn.vid.ly/4m8d9f/mp4.mp4" type="video/mp4"><source src="http://cf.cdn.vid.ly/4m8d9f/webm.webm" type="video/webm"><source src="http://cf.cdn.vid.ly/4m8d9f/ogv.ogv" type="video/ogg"><a target='_blank' href='http://vid.ly/4m8d9f'><img   src='http://cf.cdn.vid.ly/4m8d9f/poster.jpg' width="500"></a></video></p>
<p>To celebrate the release and to show how CSS 3D can be applied as subtle effect, have a <a href="http://thewebrocks.com/demos/browsermemory/">game of pairs using your favourite browsers (and a cat)</a> : </p>
<p><a href="http://thewebrocks.com/demos/browsermemory/"><img src="http://farm7.static.flickr.com/6112/6283741113_b3604d4ee5_o.jpg" alt="browser pairs"></a></p>
<p>Oleg Romashin also spent some time to <a href="http://romaxa.bolshe.net/css3d/">convert a few CSS 3D demos to work with Mozilla</a> and you can <a href="http://m8y.org/tmp/cubiq.org/dropbox/3dcity/index2.html">check the 3D city</a> for more &#8220;wow&#8221;.</p>
<p>If you are new to CSS 3D transformations <a href="http://24ways.org/2010/intro-to-css-3d-transforms">here&#8217;s a good beginner course</a> and <a href="http://www.westciv.com/tools/3Dtransforms/index.html">a tool to create them</a>. </p>
<p>The rotating HTML5 logo demo also shows how you can check if the currently used browser supports 3D transforms. Instead of repeating the animation frames for all the prefixes we test in JavaScript and create the CSS on the fly:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> checksupport<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> props <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'perspectiveProperty'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'WebkitPerspective'</span><span style="color: #339933;">,</span>
               <span style="color: #3366CC;">'MozPerspective'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'OPerspective'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'msPerspective'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
      i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
      support <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>props<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>props<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #000066; font-weight: bold;">in</span> form.<span style="color: #660066;">style</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      support <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      pfx <span style="color: #339933;">=</span> props<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Perspective'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      pfx <span style="color: #339933;">=</span> pfx.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    i<span style="color: #339933;">++;</span>
  <span style="color: #009900;">&#125;</span> 
  <span style="color: #000066; font-weight: bold;">return</span> support<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>checksupport<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
  styles <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  s <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'#stage{-'</span><span style="color: #339933;">+</span> pfx <span style="color: #339933;">+</span><span style="color: #3366CC;">'-perspective: 300px;}'</span><span style="color: #339933;">+</span>
       <span style="color: #3366CC;">'#logo{-'</span><span style="color: #339933;">+</span> pfx <span style="color: #339933;">+</span><span style="color: #3366CC;">'-transform-style: preserve-3d;position:relative;}'</span><span style="color: #339933;">+</span>  
       <span style="color: #3366CC;">'#logo.spin{-'</span><span style="color: #339933;">+</span> pfx <span style="color: #339933;">+</span><span style="color: #3366CC;">'-animation: spin 3s infinite linear;}'</span><span style="color: #339933;">+</span>
       <span style="color: #3366CC;">'@-'</span><span style="color: #339933;">+</span> pfx <span style="color: #339933;">+</span><span style="color: #3366CC;">'-keyframes spin {'</span><span style="color: #339933;">+</span>  
       <span style="color: #3366CC;">'0% {'</span><span style="color: #339933;">+</span> 
       <span style="color: #3366CC;">'-'</span><span style="color: #339933;">+</span> pfx <span style="color: #339933;">+</span><span style="color: #3366CC;">'-transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);'</span><span style="color: #339933;">+</span>   
       <span style="color: #3366CC;">'}'</span><span style="color: #339933;">+</span>
       <span style="color: #3366CC;">'100% {'</span><span style="color: #339933;">+</span>   
       <span style="color: #3366CC;">'-'</span><span style="color: #339933;">+</span> pfx <span style="color: #339933;">+</span><span style="color: #3366CC;">'-transform: rotateX(0deg) rotateY(360deg)'</span><span style="color: #339933;">+</span>
       <span style="color: #3366CC;">' rotateZ(360deg);'</span><span style="color: #339933;">+</span> 
       <span style="color: #3366CC;">'}}'</span><span style="color: #339933;">;</span>
  styles.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> s<span style="color: #339933;">;</span>
  document.<span style="color: #660066;">querySelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>styles<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>For more information on creating your own pages that use 3D transformations, take a look at the <a href="http://dev.w3.org/csswg/css3-3d-transforms/">draft specification</a></p>
<p>As always, If you find any bugs, please report them at <a href="https://bugzilla.mozilla.org">bugzilla.mozilla.org</a>!</p>
<p>So please reward our hard work bringing the third dimension to Firefox&#8217;s CSS engine by supporting and testing. Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/10/css-3d-transformations-in-firefox-nightly/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
<enclosure url="http://cf.cdn.vid.ly/5l3j6a/mp4.mp4" length="6843288" type="video/mp4" />
<enclosure url="http://cf.cdn.vid.ly/5l3j6a/webm.webm" length="6684672" type="video/webm" />
<enclosure url="http://cf.cdn.vid.ly/5l3j6a/ogv.ogv" length="6626659" type="video/ogg" />
<enclosure url="http://cf.cdn.vid.ly/4m8d9f/mp4.mp4" length="6138097" type="video/mp4" />
<enclosure url="http://cf.cdn.vid.ly/4m8d9f/webm.webm" length="6887958" type="video/webm" />
<enclosure url="http://cf.cdn.vid.ly/4m8d9f/ogv.ogv" length="13626193" type="video/ogg" />
		</item>
		<item>
		<title>More details about the WebAPI effort</title>
		<link>http://hacks.mozilla.org/2011/08/more-details-about-the-webapi-effort/</link>
		<comments>http://hacks.mozilla.org/2011/08/more-details-about-the-webapi-effort/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 21:19:06 +0000</pubDate>
		<dc:creator>Jonas Sicking</dc:creator>
				<category><![CDATA[Device APIs]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Developers]]></category>
		<category><![CDATA[WebAPI]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=9299</guid>
		<description><![CDATA[As we&#8217;ve hoped, there has been a lot of interest in the newly announced WebAPI effort. So I figured that I should explain in more detail some of my thinking around what we&#8217;re hoping to do and the challenges that are ahead of us. Goal The goal of this effort is to create APIs to [...]]]></description>
			<content:encoded><![CDATA[<p>As we&#8217;ve hoped, there has been a lot of interest in the <a href="http://hacks.mozilla.org/2011/08/introducing-webapi/">newly announced WebAPI effort</a>. So I figured that I should explain in more detail some of my thinking around what we&#8217;re hoping to do and the challenges that are ahead of us.</p>
<p><H2>Goal</h2>
<p>The goal of this effort is to create APIs to expand what the Web can do. We don&#8217;t want people to end up choosing to develop for a proprietary platform just because the Web is lacking some capability.</p>
<p>The main effort, at least initially, is to enable access to hardware connected to the device, and data which is stored or available to the device. As for hardware, we want to make the full range of hardware that people use available to the web platform. From common hardware like cameras, to more rarely used (but no less awesome) hardware like USB-driven Nerf cannons. We also want to enable communication hardware like Bluetooth and NFC.</p>
<p>For data stored on the device, the most commonly discussed data today is contacts and calendar. This includes the ability to both read and write data. That is, we both want the Web platform to be able to enumerate contacts stored on the device, and read their details, as well as add and remove contacts. In short, we want it to be possible to create a Web page or Web app which lets the user manage his contact list. Same thing for calendar events and other types of data stored on devices.</p>
<h2>Security and Privacy</h2>
<p>One big reason these types of APIs haven&#8217;t been developed for the Web platform yet is because of their security and privacy implications. I would obviously not want every single Web page out there to be able to mess around with my contact list or my calendar. And being able to issue any commands to any USB device that I happen to have plugged in would likely result in everyone&#8217;s computer immediately being zombified.</p>
<p>So as we are developing these APIs, we always have to develop a security model to go along with them. In some cases simply asking the user, which is how we currently do Geolocation, might work. In others, where security implications are scarier or where describing the risk to the user is harder, we&#8217;ll have to come up with better solutions.</p>
<p>I really want to emphasize that we don&#8217;t yet know what the security story is going to be, but that we&#8217;re absolutely planning on having a solid security solution before we ship an API to millions of users.</p>
<p><a href="http://robert.ocallahan.org/">Robert O&#8217;Callahan</a> has a really great post about <a href="http://robert.ocallahan.org/2011/06/permissions-for-web-applications_30.html">permissions for Web applications</a>.</p>
<h2>Standards</h2>
<p>Mozilla has always had a strong commitment to Web standards. This is of course not something we&#8217;re changing! All of the APIs that we are developing will be developed with the goal of being standardized and implemented across both browsers and devices.</p>
<p>But it&#8217;s important to ensure that standards are good standards. This takes experimenting. Especially in areas which are as new to the Web, and as security sensitive, as these are.</p>
<p>Standards organizations aren&#8217;t a good place to do research. This is why we want to experiment and do research outside the standards organizations first. But always in the open, and always listening to feedback. We&#8217;re also going to clearly prefix any APIs as to indicate that they are experiments and might change once they get standardized.</p>
<p>Once we have a better understanding of what we think makes a good API we will create a proposal and bring to working groups like the <a href="http://www.w3.org/2009/dap/">Device API</a> group at <a href="http://www.w3.org/">W3C</a>, <a href="http://www.wacapps.net/">WAC</a> and <a href="http://www.whatwg.org/">WHATWG</a>.</p>
<p>Throughout this process we will of course be in contact with other interested parties, such as other browser vendors and web developers. This is part of the normal research and making sure that an API is a good API.</p>
<p>Mozilla always has and always will be a good steward of the open Web. We are not interested in creating a Mozilla-specific Web platform. We are interested in moving the open Web platform forward.</p>
<h2>High Level vs. Low Level</h2>
<p>One thing that often comes up with API design is whether we should do high level or low level APIs. For example, do we provide a low-level USB API, or a high-level API for cameras?</p>
<p>There are pros and cons with both. High level means that we can create more developer-friendly APIs. We can also provide a better security model since we can ensure that the page won&#8217;t issue any unexpected USB commands, and we can ensure that no privacy-sensitive access is made without user approval. But high level also means that developers can&#8217;t access a type of device until we&#8217;ve added support for it. So until we&#8217;ve added an API for Nerf cannons, there will be no way to talk to them.</p>
<p>Exposing a low-level USB API on the other hand, means that web pages can talk to any USB device in existence, with no need for us to add an explicit API for them. However it also requires developers to get their hands dirty with the details of the USB protocol and differences between devices.</p>
<p>The approach we&#8217;re planning on taking is to do both high-level and low-level APIs, as well as give people the proper incentives to use the one that is best for the user. But a very important point is to provide low-level APIs early to ensure that Mozilla isn&#8217;t on the critical path for innovation. Over time, we can add high-level APIs where that makes sense.</p>
<h2>How you can join</h2>
<p>As with all things Mozilla, we&#8217;re planning on doing all our work in the open. In fact, we&#8217;ll be relying on your help to make this successful! As to keep discussions focused, we&#8217;re going to use the a new mozilla.dev.webapi discussion forum for all communication. This means that you can participate through email, newsgroups, or the web-based google group UI.</p>
<p>You can subscribe to the mailing list at <a href="https://lists.mozilla.org/listinfo/dev-webapi">https://lists.mozilla.org/listinfo/dev-webapi</a></p>
<p>For other methods go to: <a href="http://www.mozilla.org/about/forums/#dev-webapi">http://www.mozilla.org/about/forums/#dev-webapi</a></p>
<p>We also use the <a href="irc://irc.mozilla.org/#webapi">#webapi</a> IRC channel on <a href="irc://irc.mozilla.org/">irc.mozilla.org</a>.</p>
<p>We&#8217;ll also be tracking progress on the wiki page <a href="https://wiki.mozilla.org/WebAPI">https://wiki.mozilla.org/WebAPI</a></p>
<p>Looking forward to hearing from you to help build the next stage for the web platform!</p>
<h2>Hiring developers</h2>
<p><strong>Edit:</strong> Forgot to mention, we are hiring several full time engineers for working on the WebAPI team! <a href="http://hire.jobvite.com/CompanyJobs/Careers.aspx?c=qpX9Vfwa&#038;cs=9Kt9Vfw1&#038;page=Job%20Description&#038;j=oIvPVfwH">Read the job description and apply</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/08/more-details-about-the-webapi-effort/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Introducing WebAPI</title>
		<link>http://hacks.mozilla.org/2011/08/introducing-webapi/</link>
		<comments>http://hacks.mozilla.org/2011/08/introducing-webapi/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 10:42:18 +0000</pubDate>
		<dc:creator>Robert Nyman</dc:creator>
				<category><![CDATA[Device APIs]]></category>
		<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[WebAPI]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=9288</guid>
		<description><![CDATA[Mozilla would like to introduce WebAPI with the goal to provide a basic HTML5 phone experience within 3 to 6 months. The current situation Where we are today, there&#8217;s a clear distinction between the Open Web and native APIs and how things have to be built. As many developers are aware of, we need consistent [...]]]></description>
			<content:encoded><![CDATA[<p>Mozilla would like to introduce <a href="https://wiki.mozilla.org/WebAPI">WebAPI</a> with the goal to provide a basic HTML5 phone experience within 3 to 6 months.</p>
<p><span id="more-9288"></span></p>
<h2>The current situation</h2>
<p>Where we are today, there&#8217;s a clear distinction between the Open Web and native APIs and how things have to be built. As many developers are aware of, we need consistent APIs across web browsers, operating systems and devices to be able to build something for the world, not just a specific device or vendor. We need a way to take the web to the next step.</p>
<h2>What is WebAPI?</h2>
<p>WebAPI is an effort by Mozilla to bridge together the gap, and have consistent APIs that will work in all web browsers, no matter the operating system. Specification drafts and implementation prototypes will be available, and it will be submitted to W3C for standardization. Security is a very important factor here, and it will be a mix of existing security measurements (e.g. asking the user for permission, like Geolocation) or coming up with new alternatives to ensure this.</p>
<p>In the nearest timeframe we are looking into building:</p>
<ul>
<li><strong>Dialer:</strong> Telephony &amp; Messaging API, Contacts API</li>
<li><strong>Address Book:</strong> Contacts API</li>
<li><strong>SMS:</strong> Telephony &amp; Messaging API, Contacts API</li>
<li><strong>Clock</strong></li>
<li><strong>Camera:</strong> Camera API, Filesystem API</li>
<li><strong>Gallery:</strong> Filesystem API (could possibly be FileReader &amp; FileWriter in conjunction)</li>
<li><strong>Calculator</strong></li>
<li><strong>Settings:</strong> Device Status API, Settings API</li>
<li><strong>Games:</strong> Accelerometer API, Mouse Lock API</li>
<li><strong>Maps:</strong> Geolocation API, Contacts API</li>
</ul>
<h2>Contribute</h2>
<p>We know that there are so many talented people out there with great input, so please contribute through any of these means:</p>
<ul>
<li>Keep track of the <a href="https://wiki.mozilla.org/WebAPI">WebAPI project page</a>.</li>
<li><a href="http://groups.google.com/group/mozilla.dev.webapi/topics">The WebAPI mailing list</a>.</li>
<li>IRC: <a href="http://irc.mozilla.org/">irc.mozilla.org</a> in the #webapi room.</li>
<li>Start working by going to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=673923">bug 67392</a> and look at the dependent bugs to find the ones that need help.</li>
</ul>
<h2>Hiring developers</h2>
<p>We are also hiring several full time engineers for working with WebAPI. <a href="http://hire.jobvite.com/CompanyJobs/Careers.aspx?c=qpX9Vfwa&amp;cs=9Kt9Vfw1&amp;page=Job%20Description&amp;j=oIvPVfwH">Read the job description and apply</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/08/introducing-webapi/feed/</wfw:commentRss>
		<slash:comments>103</slash:comments>
		</item>
		<item>
		<title>Accessibility and web innovation &#8211; a constant struggle</title>
		<link>http://hacks.mozilla.org/2011/04/accessibility-and-web-innovation-a-constant-struggle/</link>
		<comments>http://hacks.mozilla.org/2011/04/accessibility-and-web-innovation-a-constant-struggle/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 14:57:32 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Developers]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=7887</guid>
		<description><![CDATA[I just came back from a small &#8220;accessibility tour&#8221; giving a talk about accessibility and web innovation in Stockholm, Sweden at Funkas Tillgänglighetsdagar and then in Paris at the W3Cafe meetup. In essence what I was musing about is that there is still a massive disconnect between accessibility and the development world. Accessibility is not [...]]]></description>
			<content:encoded><![CDATA[<p>I just came back from a small &#8220;accessibility tour&#8221; giving a talk about accessibility and web innovation in Stockholm, Sweden at <a href="http://www.funkanu.se/Tillganglighetsdagar">Funkas Tillgänglighetsdagar</a> and then in Paris at the <a href="http://fr.amiando.com/W3Cafe_accessibilite.html">W3Cafe meetup</a>. </p>
<p>In essence what I was musing about is that there is still a massive disconnect between accessibility and the development world. Accessibility is not seen as something that is cool and bleeding edge but as a necessary evil. If you ask about accessibility on developer mailing lists that juggle HTML5, Node.js, CSS3 and other cool technologies with ease you are very likely to hear that people are considering as an afterthought or make sure that &#8220;the interface degrades gracefully&#8221;. </p>
<p>When you ask the accessibility world about cool new technologies you are very likely to hear that they may be interesting in a few years but are not ready yet and certainly will never be accessible in a legal sense. </p>
<p>Having been positioned in between these two parties for a long time I am getting tired of this and I want the two fractions to move closer to each other. </p>
<p>Accessibility is part of everything we do &#8211; the physical world has become much better in the last decades because we care for the needs of people with disabilities. Lowered kerbs on sidewalks, OCR Scanning, subtitles and captions on movies and TV programs &#8211; these are all things invented for a disability need but we all now benefit from it. The same can and should happen in interface design and web development. If you think about it, the features that make a good mobile interface also cover a lot of needs of different disability groups. So why don&#8217;t we work together?</p>
<p>You can see the slides of the talk on Slideshare:</p>
<p>You can get the <a href="http://www.slideshare.net/cheilmann/accessibility-and-web-innovation-no-notes">slide deck on Slideshare</a>:</p>
<p><iframe style="border:none;width:550px;height:458px;" src="http://icant.co.uk/slidesharehtml/embed.php?url=http://www.slideshare.net/cheilmann/accessibility-and-web-innovation-no-notes&#038;width=500"></iframe></p>
<p>The <a href="http://www.archive.org/details/AccessibilityAndWebInnovation">audio of the talk</a> is available at archive.org:</p>
<p><audio controls="true" style="display:block;margin:1em;"><source src="http://www.archive.org/download/AccessibilityAndWebInnovation/AccessibilityAndWebInnovation.mp3" type="audio/mp3"><source src="http://www.archive.org/download/AccessibilityAndWebInnovation/AccessibilityAndWebInnovation.ogg" type="audio/ogg"></audio>  </p>
<p>There are also <a href="http://www.wait-till-i.com/2011/04/18/accessibility-and-web-innovation-a-talk/">extensive notes on the talk</a> available on my blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/04/accessibility-and-web-innovation-a-constant-struggle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://www.archive.org/download/AccessibilityAndWebInnovation/AccessibilityAndWebInnovation.ogg" length="0" type="audio/ogg" />
<enclosure url="http://www.archive.org/download/AccessibilityAndWebInnovation/AccessibilityAndWebInnovation.mp3" length="0" type="audio/mpeg" />
		</item>
		<item>
		<title>Multimedia on the web and using HTML5 sensibly</title>
		<link>http://hacks.mozilla.org/2011/02/multimedia-on-the-web-and-using-html5-sensibly/</link>
		<comments>http://hacks.mozilla.org/2011/02/multimedia-on-the-web-and-using-html5-sensibly/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 17:52:41 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Developers]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[discussion]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[pragmatism]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=7228</guid>
		<description><![CDATA[Last week I went to the London Ajax User Meetup in London, England to deliver two talks about HTML5. One was a re-run of a talk I gave at MIT about Multimedia on the web and the second was a call to arms to use HTML5 sensibly. You can go over to Skillsmatter web site [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I went to the <a href="http://www.meetup.com/londonajax/events/16023271/">London Ajax User Meetup</a> in London, England to deliver two talks about HTML5. One was a re-run of a talk I gave at MIT about Multimedia on the web and the second was a call to arms to use HTML5 sensibly. You can go over to <a href="http://skillsmatter.com/podcast/ajax-ria/using-html5-sensibly-and-how-to-cheat-by-using-the-web/rl-311">Skillsmatter web site to see both talks back to back</a> &#8211; but be sure to catch the notes to the second talk in this post, too.</p>
<p>In addition to my notes here there is also a <a href="http://blog.caplin.com/2011/02/09/multimedia-on-the-webusing-html5-sensibly-review/">great write-up of the evening by Ian Alderson</a> available on the web.</p>
<h2>Multimedia on the web</h2>
<p>We&#8217;ve covered this talk before in the <a href="http://hacks.mozilla.org/2011/01/talking-about-html5-games-development-at-mit-in-boston/">blog post here </a> and you can <a href="http://www.wait-till-i.com/2011/01/16/lecturing-at-mit-about-html5-video-slides-and-lots-of-notes/">read the extensive notes for the whole talk with code examples on my blog</a>. The <a href="http://www.slideshare.net/cheilmann/multimedia-on-the-web-html5-video-and-audio">slides of the multimedia talk are on slideshare</a> and here:</p>
<p><iframe style="border:none;width:550px;height:458px;" src="http://icant.co.uk/slidesharehtml/embed.php?url=http://www.slideshare.net/cheilmann/multimedia-on-the-web-html5-video-and-audio&#038;width=500"></iframe></p>
<p>You can <a href="http://vid.ly/8x6a9m">see &#8220;Multimedia on the web&#8221; on any HTML5 enabled device here</a> (courtesy of vid.ly) or embedded here:</p>
<p><video src="http://vid.ly/8x6a9m?content=video" controls width="500"><a href="http://vidly.s3.amazonaws.com/8x6a9m/mp4.mp4">Download &#8220;Multimedia on the web&#8221; as MP4</a></video></p>
<h2>Using HTML5 sensibly</h2>
<p>Using HTML5 sensibly was a talk I wanted to give for a long time. Rather than just giving the facts, I wanted to raise some questions every developer should ask themselves, the HTML5 working groups and everyone who cares to listen. We are in the middle of a big change in our development environment and not many people realise that we are breaking a lot of old conventions without fallback.</p>
<p>You can <a href="http://www.slideshare.net/cheilmann/using-html5-sensibl">get the slides on Slideshare or see them here:</a></p>
<p><iframe style="border:none;width:550px;height:458px;" src="http://icant.co.uk/slidesharehtml/embed.php?url=http://www.slideshare.net/cheilmann/using-html5-sensibl&#038;width=500"></iframe></p>
<p>You can <a href="http://vid.ly/4w0l0v">see &#8220;Using HTML5 sensibly&#8221; on any HTML5 enabled device here</a> (courtesy of vid.ly).</p>
<p><video src="http://vid.ly/4w0l0v?content=video" controls width="500"><a href="http://vidly.s3.amazonaws.com/4w0l0v/mp4.mp4">Download &#8220;Using HTML5 sensibly&#8221; as MP4</a></video></p>
<h3>Notes on &#8220;Using HTML5 sensibly&#8221;</h3>
<p>I started the talk by telling the story of <a href="http://en.wikipedia.org/wiki/Antarctic_Snow_Cruiser">the Antarctic Snow Cruiser</a> &#8211; a marvel of technology built in 1939 to allow a crew to explore Antarctica. The job of the Cruiser was to give the crew all the neccesary creature comforts and allow them to drive through Antarctica, which is both very cold and also features massive cracks that the vehicle somehow needs to get over. The ingenious solution was to have huge wheels that can be retracted into the Cruiser to prevent them from getting brittle over night and to push the vehicle over the cracks. The Cruiser was built in a rush and tested on the way to the port to go down to Antarctica. It was a hit with the press and people delayed the whole trip even more by wanting to have their photo taken with it. Upon arrival the vehicle almost crashed into the sea as the ramp built for its delivery onto the ice was not strong enough. Even worse, once on the ice the Cruiser couldn&#8217;t get a grip and the wheels spun uselessly, almost overheating the engine. Despite all the hype, the cruiser was a massive failure. </p>
<p>A few things went wrong with the cruiser:</p>
<ul>
<li>It was purely engineering driven</li>
<li>It was tested while on the road</li>
<li>It was never tested in the real environment</li>
<li>There was a massive media excitement before it proved its worth</li>
</ul>
<p>Much like we deal with HTML5 nowadays. A lot of the information about HTML5 is marketing driven and used to sell a certain environment or browser to people. Instead of real applications and day-to-day use web sites we <a href="http://studio.html5rocks.com/">create</a> <a href="http://www.apple.com/html5/">demo</a> <a href="http://html5advent.com/">sites</a> to show what &#8220;HTML5 can do for you&#8221;. The term HTML5 gets washed out as it is used both for implementations of parts of the specification but also for browser-specific code that only works in a certain environment. </p>
<p>This is partly because of the specifications and the different players in the HTML5 world itself. The specs do not only contain definitions of markup but also JavaScript APIs and instructions on how to write a browser that renders HTML5 content. This is great as it takes away the liberty browser vendors had in the past in &#8220;creatively&#8221; applying the HTML4 specs, but it also means that people can focus on parts of the spec and of course rant about all the other parts. You&#8217;ve probably seen one talk about the amazing cool new semantics of HTML5 markup and another about API implementations using completely non-sensical markup back to back. This is what we get right now as the specs are too big and all-encompassing for implementers.</p>
<p>One of the main topics of the HTML5 work is pragmatism &#8211; XML and strict HTML just used too many things we simply don&#8217;t need. This shows itself a lot in the simplification of a plain HTML document. In HTML4.01 strict this was:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;Content-Type&quot;</span> </span>
<span style="color: #009900;">        <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HTML - c'est moi!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/css&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;styles.css&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;magic.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Heading! Everybody duck!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>I am content, hear me roar!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;footer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>By me!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Neither the long DOCTYPE definition nor the http-equiv was ever used by browsers. It is not needed for browsers to do their job. In HTML5 this is a plain Vanilla document:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HTML5, c'est moi, ou HTML...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;styles.css&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;magic.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Heading! Everybody duck!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>I am content, hear me roar!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;footer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>By me!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Much simpler and shorter. In addition to that HTML5 also includes new semantic elements:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HTML5, c'est moi, ou HTML...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;styles.css&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;magic.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;header<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Heading! Everybody duck!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;section<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>I am content, hear me roar!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/section<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;footer<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>By me!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/footer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This gives us handles for styling and tells the browser what the different parts are. The simplification goes further though. As people never seemed to have bothered to write valid XML in HTML it is now also completely OK to mix upper and lower case and omit quotation marks around the attributes (if the attributes have one value, multi value attributes like classes need quotes around them once you add more than one value):</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=en<span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TITLE<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HTML5, c'est moi, ou HTML...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LINK</span> <span style="color: #000066;">rel</span>=stylesheet <span style="color: #000066;">href</span>=styles.css<span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=magic.js<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/SCRIPT<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;HEADER<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Heading! Everybody duck!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;section<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>I am content, hear me roar!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SECTION<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;footer<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>By me!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/FOOTER<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/HTML<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Browsers are forgiving enough to fix these inconsistencies for us. For example the generated code in Firefox is:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HTML5, c'est moi, ou HTML...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;styles.css&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;magic.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;header<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Heading! Everybody duck!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;section<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>I am content, hear me roar!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/section<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;footer<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>By me!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/footer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>However, if we were to omit the closing <code>&lt;/p&gt;</code> tag in the <code>&lt;section&gt;</code> the generated code looks different:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HTML5, c'est moi, ou HTML...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;styles.css&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;magic.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;header<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Heading! Everybody duck!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;section<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>I am content, hear me roar!
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;footer<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/footer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>By me!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/section<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>As you can see, the <code>&lt;footer&gt;</code> got moved into the paragraph inside the section. Why? Who knows? The issue is that we ask a browser to make an educated guess for us and as a browser doesn&#8217;t understand semantics, this is what we get.</p>
<p>Which leads me to a few questions we need to ask and find the answer to:</p>
<ul>
<li>Can innovation be based on &#8220;people never did this correctly anyways&#8221;?</li>
<li>Is it HTML or BML? (HyperText Markup Language or Browser Markup Language)</li>
<li>Should HTML be there only for browsers? What about conversion Services? Search bots? Content scrapers?</li>
</ul>
<p>The next issue I wanted to discuss is legacy browsers which seems to be a euphemism for IE6. The issue with IE6 is that when you use the new semantic HTML elements exclusively then they can&#8217;t be styled in this browser. By using the correct new syntax that should bring us a lot of benefits you condemn older browser users to see unstyled documents.</p>
<p>There are a few ways around this. The first one requires JavaScript &#8211; if you create the element using the DOM first you can style it in IE:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>header{color:#fff;background:#369;}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>document.createElement('header');<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;header<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hello!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This technique has been wrapped up nicely in a script called <a href="http://code.google.com/p/html5shiv/">HTML5 shiv</a> by Remy Sharp. Of course, this means that you make markup dependent on JavaScript to work which is not what markup is about, according to purists of the web. You can work around that dependency in a few ways. You can <a href="http://www.ibm.com/developerworks/xml/library/x-think45/">write HTML5 as XHTML</a>, you can <a href="http://www.debeterevormgever.nl/html5-ie-without-javascript/">use conditional comments or a namespace</a> or you can use both the new semantic elements and DIVs with a class around them to please all browsers:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HTML5, c'est moi, ou HTML...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;styles.css&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;magic.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span>=<span style="color: #ff0000;">&quot;screen&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      .header,header,
      .footer,footer,
      .aside,aside,
      .section,section{
        display:block;
      }
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;header&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Heading! Everybody duck!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/header<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;section&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;section<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>I am content, hear me roar!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/section<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;footer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;footer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>By me!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/footer<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This seems to be the most pragmatic solution but is a lot of extra effort.</p>
<p>The main issue is that not only legacy browsers are failing to support HTML5 properly which is why people tend to use a library like <a href="http://www.modernizr.com/">Modernizr</a> to check for HTML5 support before applying it. Modernizr adds classes to the HTML element after checking what the current browser supports and thus gives you handles to use in progressive enhancement. All the hacks and fixes are also bundled in <a href="http://html5boilerplate.com/">HTML5 Boilerplate</a>, including server settings and ways to make legacy browsers behave. In essence, the much smaller Vanilla HTML5 markup becomes a lot of code again if you test it in the real world.</p>
<p>If you also want to use all the cool new JavaScript APIs you can use <a href="https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills">Polyfills</a> to make legacy browsers do something with the code you write.</p>
<p>Which leads to more questions we need to answer:</p>
<ul>
<li>Should we shoe-horn new technology into legacy browsers?</li>
<li>Do patches add complexity as we need to test their performance? (there is no point in giving an old browser functionality that simply looks bad or grinds it down to a halt)</li>
<li>How about moving IE fixes to the server side? Padding with DIVs with classes in PHP/Ruby/Python after checking the browser and no JS for IE?</li>
</ul>
<p>The last feature of HTML5 I want to talk about is Video and Audio. Again, there is much more complexity than meets the eye:</p>
<p>Tecnically, embedding an HTML5 video should be as simple as this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;video</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;interview.ogv&quot;</span> controls<span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;interview.ogv&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Download the video<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/video<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Once you consider all the different formats needed for different browsers though it becomes a lot more work:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;video</span> controls<span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;interview.mp4&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;video/mp4&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;interview.webm&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;video/webm&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;interview.ogv&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;video/ogg&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Download the 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;interview.mp4&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>video in MP4 format<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>.
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/video<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The reason is intellectual property, legal codec battles and implementation of video in different browsers and platforms. In essence, you need to provide the video in three formats. Of course when there is a need then some company will come up with a solution. <a href="http://vid.ly">Vid.ly is a service by encoding.com</a> that provides you with a single URL that sends the video in the right format to the device you use. All in all they create 28 different formats for you to cater for all kind of mobiles and browsers. </p>
<p>The other big issue with HTML5 video is that there is no protection from downloading the videos. This is as intended but a big problem when it comes to premium content on the web. As <a href="http://www.webkitchen.be/2011/01/26/stealing-content-was-never-easier-than-with-html5/">discussed in the comments of this post by Adobe</a> publishers want to have a way to stop people from downloading and reusing their videos but instead just want their audience to watch them in a closed environment. </p>
<p>All in all there are a few questions to answer when it comes to HTML5 video:</p>
<ul>
<li>Can we expect content creators to create video in many formats to support an open technology?</li>
<li>Can a service like vid.ly be trusted for content creation and storage?</li>
<li>Is HTML5 not applicable for premium content?</li>
</ul>
<p>In the end, I want every developer and designer out there to take a stand and demand answers to these questions. There is no point in just saying &#8220;that&#8217;s how it is&#8221;. When we keep our technologies closed and  when we rely on scripting to make web sites work we do break the web in the long run. The <a href="http://simonwillison.net/tags/hashbanghell/">current debate about hashbangs</a> for links shows this.</p>
<p>Everybody can take part in the <a href="http://www.whatwg.org/mailing-list">HTML5 working group</a> and <a href="https://developer.mozilla.org/">add documentation to MDN</a> &#8211; time to get to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/02/multimedia-on-the-web-and-using-html5-sensibly/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
<enclosure url="http://vidly.s3.amazonaws.com/8x6a9m/mp4.mp4" length="290086214" type="video/mp4" />
<enclosure url="http://vidly.s3.amazonaws.com/4w0l0v/mp4.mp4" length="0" type="video/mp4" />
		</item>
		<item>
		<title>People of HTML5 &#8211; Remy Sharp</title>
		<link>http://hacks.mozilla.org/2011/01/people-of-html5-remy-sharp/</link>
		<comments>http://hacks.mozilla.org/2011/01/people-of-html5-remy-sharp/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 10:27:25 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[Audio]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[IndexedDB]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Offline]]></category>
		<category><![CDATA[People of HTML5]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[Web Developers]]></category>
		<category><![CDATA[chrisheilmann]]></category>
		<category><![CDATA[peopleofhtml5]]></category>
		<category><![CDATA[remysharp]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=7009</guid>
		<description><![CDATA[HTML5 needs spokespeople to work. There are a lot of people out there who took on this role, and here at Mozilla we thought it is a good idea to introduce some of them to you with a series of interviews and short videos. The format is simple &#8211; we send the experts 10 questions [...]]]></description>
			<content:encoded><![CDATA[<p>HTML5 needs spokespeople to work. There are a lot of people out there who took on this role, and here at Mozilla we thought it is a good idea to introduce some of them to you with a series of interviews and short videos. The format is simple &#8211; we send the experts 10 questions to answer and then do a quick video interview to let them introduce themselves and ask for more detail on some of their answers.</p>
<p><a href="http://www.html5today.it/news/people-of-html5-chris-heilmann-intervista-remy-sharp">Leggi la traduzione in italiano</a></p>
<p><a href="http://www.flickr.com/photos/remysharp/5176768276/" title="Remy Sharp by Remy Sharp, on Flickr"><img src="http://farm5.static.flickr.com/4125/5176768276_b1934d74a9_m.jpg" width="159" height="240" alt="Remy Sharp" style="float:left;margin:5px"></a>Today we are featuring <a href="http://remysharp.com">Remy Sharp</a> co-author of <a href="http://introducinghtml5.com/">Introducing HTML5</a> and organiser of the <a href="http://2010.full-frontal.org/">Full Frontal</a> conference in Brighton, England. </p>
<p>Remy is one of those ubiquitous people of HTML5. Whenever something needed fixing, there is probably something on GitHub that Remy wrote that helps you. He is also very English and doesn&#8217;t mince his words much.  </p>
<p>You can find Remy on Twitter as <a href="http://twitter.com/rem">@rem</a>. </p>
<h2 style="clear:both">The video interview</h2>
<p><video controls="true" height="295" width="480"><source src="http://www.archive.org/download/PeopleOfHtml5-RemySharp/remy_512kb.mp4" type="video/mp4"><source src="http://www.archive.org/download/PeopleOfHtml5-RemySharp/remy.webm" type="video/webm"><source src="http://www.archive.org/download/PeopleOfHtml5-RemySharp/remy.ogv" type="video/ogg">Your browser does not support the video tag, <a href="http://www.youtube.com/watch?v=fWwTv_AhFgw">check the video on YouTube</a>.</video></p>
<p><a href="http://www.youtube.com/watch?v=fWwTv_AhFgw">Watch the video on YouTube</a> or Download it from <a href="http://www.archive.org/details/PeopleOfHtml5-RemySharp">Archive.org</a> as <a href="http://www.archive.org/download/PeopleOfHtml5-RemySharp/remy_512kb.mp4">MP4 (98 MB)</a>, <a href="http://www.archive.org/download/PeopleOfHtml5-RemySharp/remy.ogv">OGG (70 MB)</a> or <a href="http://www.archive.org/download/PeopleOfHtml5-RemySharp/remy.webm">WebM (68MB)</a></p>
<h2>Ten questions about HTML5 for Remy Sharp</h2>
<h3>1) Reading &#8220;Introducing HTML5&#8243; it seems to me that you were more of the API &#8211; focused person and Bruce the markup guy. Is that a fair assumption? What is your background and passion?</h3>
<p>That&#8217;s spot on.  Bruce asked me to join the project as the &#8220;JavaScript guy&#8221; &#8211; which is the slogan I wear under my clothes and frequently reveal in a superman &#8216;spinning around&#8217; fashion (often at the surprise of clients).</p>
<p>My background has always been coding &#8211; even from a young age, my dad had me copying out listings from old spectrum magazines only to result in hours of typing and some random error that I could never debug.</p>
<p>As I got older I graduated to coding in C but those were the days the SDKs were 10Mb downloaded over a 14kb modem, and compile in to some really odd environment.  Suffice to say I didn&#8217;t get very far.</p>
<p>Then along came JavaScript.  A programming language that didn&#8217;t require any special development environment.  I could write the code in Notepad on my dodgy Window 95 box, and every machine came with the runtime: the browser.  Score!</p>
<p>From that point on the idea of instant gratification from the browser meant that I was converted &#8211; JavaScript was the way for me.</p>
<p>Since then I&#8217;ve worked on backend environments too (yep, I&#8217;m a Perl guy, sorry!), but always worked and played in the front end in some way or another.  However, since started on my own in 2006, it&#8217;s allowed me to move focus almost entirely on the front end, and specialise in JavaScript.  Basically, work-wise: I&#8217;m a pig in shit <strong>[Ed: for our non-native English readers, he means "happy")]</strong>.</p>
<h3>2) From a programmer&#8217;s point of view, what are the most exciting bits about the HTML5 standard? What would you say is something every aspiring developer should get their head around first?</h3>
<p>For me, the most exciting aspects of HTML5 is the depth of the JavaScript APIs.  It&#8217;s pretty tricky to explain to Joe Bloggs that actually this newly spec&#8217;ed version of HTML isn&#8217;t mostly HTML; it&#8217;s mostly JavaScript.  </p>
<p>I couldn&#8217;t put my finger on one single part of the spec, only because it&#8217;s like saying which is your favourite part of CSS (the :target selector &#8211; okay, so I can, but that&#8217;s not the point!).  What&#8217;s most exciting to me is that HTML5 is saying that the browser is the platform that we can deliver real applications &#8211; take this technology seriously.</p>
<p>If an aspiring developer wanted something quick and impressive, I&#8217;d say play around with the video API &#8211; by no means is this the best API, just an easy one. </p>
<p>If they really wanted to blow people away with something amazing using HTML5, I&#8217;d say learn JavaScript (I&#8217;m assuming they&#8217;re already happy with HTML and CSS). Get a book like JavaScript: The Good Parts and then get JavaScript Patterns and master the language. Maybe, just maybe, then go buy Introducing HTML5, it&#8217;s written by two /really/ good looking (naked) guys: <a href="http://flic.kr/p/8iyQTE">http://flic.kr/p/8iyQTE</a> and <a href="http://flic.kr/p/8iy6Z1">http://flic.kr/p/8iy6Z1</a> <strong>[Ed: maybe NSFW, definitely disturbing]</strong>.</p>
<h3>3) In your book you wrote a nice step-by-step video player for HTML5 video. What do you think works well with the Video APIs and what are still problems that need solving?</h3>
<p>The media API is dirt simple, so it means working with video and audio is a doddle. For me, most of it works really well (so long as you understand the loading process and the events). </p>
<p>Otherwise what&#8217;s really quite neat, is the fact I can capture the video frames and mess with them in a canvas element &#8211; there&#8217;s lots of fun that can be had there (see some of <a href="http://people.mozilla.com/~prouget/demos/">Paul Rouget&#8217;s demos</a> for that!).</p>
<p>What sucks, and sucks hard, is the spec asks vendors, ie. browser makers, *not* to implement full screen mode. It uses security concerns as the reason (which I can understand), but Flash solved this long ago &#8211; so why not follow their lead on this particular problem? If native video won&#8217;t go full screen, it will never be a competitive alternative to Flash for video. </p>
<p>That all said, I do like that the folks behind WebKit went and ignored the spec, and implemented full screen. The specs are just guidelines, and personally, I think browsers should be adding this feature. </p>
<h3>4) Let&#8217;s talk a bit about non-HTML5 standards, like Geolocation. I understand you did some work with that and found that some parts of the spec work well whilst others less so. Can you give us some insight?</h3>
<p>On top of HTML5 specification there&#8217;s a bunch more specs that make the browser really, really exciting. If we focus on the browser being released today (IE9 included) there&#8217;s a massive amount that can be done that we couldn&#8217;t do 10 years ago. </p>
<p>There&#8217;s the &#8220;non-HTML5&#8243; specs that actually were part of HTML5, but split out for good reason (so they can be better managed), like web storage, 2D canvas API and Web Sockets, but there&#8217;s also the /really/ &#8220;nothing-to-do-with-HTML5&#8243; APIs (NTDWH5API!) like querySelector, XHR2 and the Device APIs. I&#8217;m super keen to try all of these out even if they&#8217;re not fully there in all the browsers. </p>
<p>Geolocation is a great example of cherry picking technology. Playing against the idea that the technology isn&#8217;t fully implemented. Something I find myself ranting on and on about when it comes to the question of whether a developer should use HTML5.  Only 50% of Geolocation is implemented in the browsers supporting it, in that they don&#8217;t have altitude, heading or speed &#8211; all of which are part of the spec. Does that stop mainstream apps like Google Maps from using the API? (clue: no).</p>
<p>The guys writting the specs have done a pretty amazing job, and in particular there are few cases where the specs have been retrospectively written.  XHR is one of these and now we&#8217;ve got a stable API being added in new browsers (i.e. IE6 sucks, yes, we all know that).  Which leads us to drag and drop.  The black sheep of the APIs.  In theory a really powerful API that could make our applications rip, but the technical implementation is a shambles.  <a href="http://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html">PPK (Peter-Paul Koch) tore the spec a bit of a &#8216;new one&#8217;</a>.  It&#8217;s usable, but it&#8217;s confusing, and lacking.</p>
<p>Generally, I&#8217;ve found the &#8220;non-HTML5&#8243; specs to be a bit of mixed bag.  Some are well supported in new browsers, some not at all.  SVG is an oldie and now really viable with the help of JavaScript libraries such as <a href="http://raphaeljs.com">Raphaël.js</a> or <a href="http://code.google.com/p/svgweb/">SVGWeb</a> (a Flash based solution). All in all, there&#8217;s lots of options available in JavaScript API nowadays compared to back in the dark ages. </p>
<h3>5) Let&#8217;s talk Canvas vs. SVG for a bit. Isn&#8217;t Canvas just having another pixel-based rectangle in the page much like Java Applets used to be? SVG, on the other hand is Vector based and thus would be a more natural tool to do something with open standards that we do in Flash now. When would you pick SVG instead of Canvas and vice versa?</h3>
<p>Canvas, in a lot of ways is just like the Flash drawing APIs.  It&#8217;s not accessible and a total black box.  The thing is, in the West, there&#8217;s a lot of businesses, rightly or wrongly, that want their fancy animation thingy to work on iOS.  Since Flash doesn&#8217;t work there, canvas is a superb solution.</p>
<p>However, you must, MUST, decide which technology to use.  Don&#8217;t just use canvas because you saw a <a href="http://blog.nihilogic.dk/2008/05/javascript-super-mario-kart.html">Mario Kart demo</a> using it.  Look at the pros and cons of each.  SVG and the canvas API are not competitive technologies, they&#8217;re specially shaped hammers for specific jobs.</p>
<p>Brad Neuberg did a superb job of summarising the pros and cons of each, and I&#8217;m constantly referring people to it (here&#8217;s the <a href="http://www.youtube.com/watch?v=siOHh0uzcuY#t=17m00s">video</a>).</p>
<p>So it really boils down to:</p>
<ul>
<li>Canvas: pixel manipulation, non-interactive and high animation</li>
<li>SVG: interactive, vector based</li>
</ul>
<p>Choose wisely young padawan!</p>
<h3>6) What about performance? Aren&#8217;t large Canvas solutions very slow, especially on mobile devices? Isn&#8217;t that a problem for gaming? What can be done to work around that?</h3>
<p>Well&#8230;yes and no.  I&#8217;m finishing a project that has a large canvas animation going on, and it&#8217;s not slow on mobile devices (not that it was designed for those).  The reason it&#8217;s not slow is because of the way the canvas animates.  It doesn&#8217;t need to be constantly updating at 60fps.</p>
<p>Performance depends on your application.  Evaluate the environment, the technologies and make a good decision.  I personally don&#8217;t think using a canvas for a really high performance game on a mobile is quite ready.  I don&#8217;t think the devices have the ommph to get the job done &#8211; but there&#8217;s a hidden problem &#8211; the browser in the device isn&#8217;t quite up to it.  Hardware acceleration is going to help, a lot, but today, right now, I don&#8217;t think we&#8217;ll see games like Angry Birds written in JavaScript.  </p>
<p>That said&hellip; I&#8217;ve seriously considered how you could replicate a game like <a href="http://www.adamatomic.com/canabalt/">Canabalt</a> using a mix of canvas, DIVs and CSS.  I think it might be doable ::throws gauntlet::</p>
<p>I think our community could actually learn a lot from the Flash community.  They&#8217;ve been through all of this already.  Trying to make old versions of Flash from years back do things that were pushing the boundaries.  People like Seb Lee-Delisle (<a href="http://twitter.com/seb_ly">@seb_ly</a> / <a href="http://seb.ly">http://seb.ly</a>) are doing an amazing job of teaching both the Flash and JavaScript community.</p>
<h3>7) A feature that used to be HTML5 and is now an own spec is LocalStorage and its derivatives Session Storage or the full-fledged WebSQL and IndexedDB. Another thing is offline storage. There seems to be a huge discussion in developer circles about what to use when and if NoSQL solutions client side are the future or not. What are your thoughts? When can you use what and what are the drawbacks?</h3>
<p>Personally I love seeing server-less applications. Looking at the storage solutions I often find it difficult to see why you wouldn&#8217;t use WebStorage every time. </p>
<p>In a way it acts like (in my limited experience of) NoSQL, in that you lookup a key and get a result. </p>
<p>Equally, I think SQL in the browser is over the top. Like you&#8217;re trying to use the storage method *you* understand and forcing it into the browser. Seems like too much work for too little win.</p>
<p>Offline Apps, API-wise, ie. the application cache is /really/ sexy. Like sexy with chocolate on top sexy. The idea that our applications can run without the web, or switch when it detects it&#8217;s offline is really powerful. The only problem is that the events are screwed. The event to say your app is now offline requires the user to intervene via the browser menu, telling the browser to &#8220;work in offline mode&#8221;. A total failure of experience. What&#8217;s worse is that, as far as I know, there&#8217;s no plan to make offline event fire properly :-(</p>
<p>That all said, cookies are definitely dead for me. I&#8217;ve yet to find a real solution for cookies since I found the Web Storage API &#8211; and there&#8217;s a good decent number of polyfills for Web Storage &#8211; so there&#8217;s really no fear of using the API. </p>
<h3>8) Changing the track a bit, you&#8217;ve built the HTML5shiv to make HTML5elements styleable in IE. This idea sparked quite a lot of other solutions to make IE6 work with the new technologies (or actually simulate them). Where does this end? Do you think it is worth while to write much more code just to have full IE6 support?</h3>
<p>There&#8217;s two things here:</p>
<ol>
<li>Supporting IE6 (clue: don&#8217;t)</li>
<li>Polyfills</li>
</ol>
<p>IE6, seriously, and for the umpteenth time, look at your users.  Seriously.  I know the project manager is going to say they don&#8217;t know what the figures are, in that case: find out!  Then, once you&#8217;ve got the usage stats in hand, you know your audience and you know what technology they support.</p>
<p>If they&#8217;re mostly IE6 users, then adding native video with spinning and dancing canvas effect isn&#8217;t going to work &#8211; not even with shims and polyfills.  IE6 is an old dog that just isn&#8217;t up to doing the mileage he used to be able to do back in his prime.  But enough on this subject &#8211; the old &#8216;do I, or don&#8217;t I developer for IE6&#8242; is long in the tooth.</p>
<p>Polyfills &#8211; that&#8217;s a different matter.  They&#8217;re not there to support IE6, they&#8217;re there to bring browsers up to your expectations as a developer.  However, I&#8217;d ask that you carefully consider them before pulling them in.  The point of these scripts is they plug missing APIs in those older browsers.  &#8220;Old browsers&#8221; doesn&#8217;t particularly mean IE6.  For example, the Web Sockets API has a polyfill by way of Flash.  If native Web Sockets aren&#8217;t there, Flash fills the gap, but the API is exposed in exactly the same manner, meaning that you don&#8217;t have to fork your code.</p>
<p>I don&#8217;t think people should be pulling in scripts just for the hell of it.  You should consider what you&#8217;re trying to achieve and decide whether X technology is the right fit.  If it is, and you know (or expect) your users have browsers that don&#8217;t support X technology &#8211; should you plug it with JavaScript or perhaps should you consider a different technology?</p>
<p>This exact same argument rings true for when someone adds jQuery just to add or remove a class from an element.  It&#8217;s simply not worth it &#8211; but clearly that particular developer didn&#8217;t really understand what they needed to do.  So is education the solution?  I should hope so.</p>
<h3>9) Where would you send people if they want to learn about HTML5? What are tutorials that taught you a lot? Where should interested people hang out?</h3>
<p><a href="http://html5doctor.com">HTML5 Doctor</a> &#8211; fo sho&#8217;.  :)</p>
<p>I tend to also direct people to my <a href="http://html5demos.com">http://html5demos.com</a> simply to encourage viewing source, and hacking away.  </p>
<p>Regarding what tutorials taught me &#8211; if I&#8217;m totally honest, the place I&#8217;ve learnt the most from is actually HTML5Doctor.com. There&#8217;s some pretty good JavaScript / API tutorials coming from the chaps at <a href="http://bocoup.com">http://bocoup.com</a>.  Otherwise, I actually spend a lot of time just snooping through the specifications, looking for bits that I&#8217;ve not seen before and generally poking them with a stick.</p>
<h3>10) You have announced that you are concentrating on building a framework to make Websockets easy to work with. How is that getting on and what do you see Websockets being used for in the future? In other words, why the fascination?</h3>
<p>Concentrating is a strong word ;-) but it is true, I&#8217;ve started working on a product that abstracts Web Sockets to a service. Not the API alone, since it&#8217;s so damn simple, but the server setup: creating sessions, user control flow, waiting for users and more. </p>
<p>The service is called Förbind. Swedish for &#8220;connect&#8221;, ie. to connect your users.  It&#8217;s still early days, but I hope to release alpha access to <a href="http://forbind.net/">forbind.net</a> this month. </p>
<p>I used to work in finance web sites and real-time was the golden egg: to get that data as soon as it was published. So now that it&#8217;s available in a native form in the browser, I&#8217;m all over it!</p>
<p>What&#8217;s more, I love the idea of anonymous users. I created a bunch of demos where the user can contribute to something without ever really revealing themselves, and when the users come, you start to see how creative people are without really trying. Sure, you get a lot of cocks being drawn, but you also see some impressive ideas &#8211; my business 404 page for example allows people to leave a drawing, one of the most impressive is a Super Mario in all his glory. Anonymous users really interest me because as grey as things can seem sometimes, a stranger can easily inspire you.</p>
<p>Do you know anyone I should interview for &#8220;People of HTML5&#8243;? Tell me on Twitter: <a href="http://twitter.com/codepo8">@codepo8</a></p>
<p><script type="text/javascript" src="http://s3.www.universalsubtitles.org/js/mirosubs-widgetizer.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2011/01/people-of-html5-remy-sharp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://www.archive.org/download/PeopleOfHtml5-RemySharp/remy_512kb.mp4" length="0" type="video/mp4" />
<enclosure url="http://www.archive.org/download/PeopleOfHtml5-RemySharp/remy.ogv" length="0" type="video/ogg" />
		</item>
		<item>
		<title>A call for quality HTML5 demo markup</title>
		<link>http://hacks.mozilla.org/2010/12/a-call-for-quality-html5-demo-markup/</link>
		<comments>http://hacks.mozilla.org/2010/12/a-call-for-quality-html5-demo-markup/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 20:32:29 +0000</pubDate>
		<dc:creator>Janet Swisher</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Developers]]></category>
		<category><![CDATA[bestpractices]]></category>
		<category><![CDATA[cleancode]]></category>
		<category><![CDATA[demos]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[maintainability]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=6836</guid>
		<description><![CDATA[HTML5 is a necessary evolution to make the web better. Before the HTML5 specs were created we used (and still use) a hacked together bunch of systems meant for describing and linking documents to create applications. We use generic elements to simulate rich interaction modules used in desktop development and we make assumptions as to [...]]]></description>
			<content:encoded><![CDATA[<p>HTML5 is a necessary evolution to make the web better. Before the HTML5 specs were created we used (and still use) a hacked together bunch of systems meant for describing and linking documents to create applications. We use generic elements to simulate rich interaction modules used in desktop development and we make assumptions as to what the user agent (browser) can do for the end user. </p>
<p>The good thing about this mess is that it taught us over the last few years to be paranoid in our development approach &#8211; we realised that in order to deliver working, accessible, maintainable and scalable systems we have to be professional and intelligent in our decisions and especially in our planning and architecting. </p>
<p>The trouble is that with the excitement around the cool new HTML5 things to play with a lot of these principles get lost and discarded as outdated. They aren&#8217;t &#8211; part of the mess that the web is in is that in 1999 a lot of people discarded everything else and instead worked only on the new hotness that was Internet Explorer 6 and DHTML. Let&#8217;s not repeat that mistake.</p>
<h2>The two faces of HTML5 enthusiasm</h2>
<p>Right now there are two things to get really excited about in HTML5: the richer, more meaningful semantics of new elements and the APIs that give us deep access into the workings of the browser and the operating system. The former allows us to build much richer interfaces and the latter allows us to build much more complex applications. </p>
<p>All of this comes with the awesome of view source (or check in development tools) for debugging. You can advocate HTML5 by writing clean and useful markup. You can kill it by treating the markup as a second class citizen which is only there to serve the script. </p>
<p>The markup enthusiasts are very happy about HTML5 and make it easy for people to upgrade &#8211; lots of cool new <a href="http://nicolasgallagher.com/anatomy-of-an-html5-wordpress-theme/">blog templates</a> and <a href="http://html5boilerplate.com/">boilerplate HTML templates</a> are being built and <a href="http://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills">polyfills</a> created to allow using the new features and not leave behind outdated browsers. </p>
<p>On the app development side of things it looks much different and that is just sad. My only possible explanation is that people who come from desktop environments now tackle the HTML5 APIs without ever having to care about markup. The pragmatism of HTML5 allows a much more forgiving syntax than XHTML but it shouldn&#8217;t mean that we can just re-apply all the bad mistakes that held us back when it comes to maintenance for years. </p>
<p>During my career as a web developer I realised a few things make a lot of sense when building web apps:</p>
<ul>
<li><strong>If there is an element for a certain task &#8211; use that one</strong>. It is very likely that the element comes with accessibility and interaction features for free that you would otherwise have to simulate.</li>
<li><strong>Separate CSS, JavaScript and HTML</strong> &#8211; which means it is easy to refactor your code without having to change all of them. It also means you can work in parallel with others instead of breaking each other&#8217;s code</li>
<li><strong>Never rely on markup or content</strong> &#8211; as sooner or later some editing tool will come into place that messes with everything you created</li>
</ul>
<p>This means a lot of things: </p>
<ul>
<li>For starters it means that inline styles are simply evil as they override any settings you have in your style sheets. Only use them when this is exactly what you need to do or when you calculate them dynamically.</li>
<li>The same applies to inline scripting. If you have an <code>onclick="foo()"</code> somewhere in your HTML and <code>foo()</code> changes to <code>bar()</code> you have to rename it in every HTML document (of course nowadays it is one template, but it still means hunting down a reference you might miss)</li>
<li>If instead of using a native HTML element for a certain job you use SPANs and DIVs you&#8217;ll have to add classes to make them look and work &#8211; and simulate the keyboard accessibility, too.</li>
<li>You can&#8217;t rely on the text value of any element. A <code>&lt;button&gt;edit&lt;/button&gt;</code> using the &#8220;edit&#8221; as the trigger for certain functionality would have to have the JS localised, too when you create the German <code>&lt;button&gt;bearbeiten&lt;/button&gt;.</code></li>
</ul>
<h2>Bla bla bla&#8230; C&#8217;mon Chris, it isn&#8217;t that bad!</h2>
<p>The above best practices have been mentioned for years and a lot of people get sick of seeing them repeated. After all, this is intelligent development and standard practice in backend technologies. I came across a lot of &#8220;creative&#8221; uses lately though when doing a view-source on HTML5 demos &#8211; specifically the ones in the HTML5 advent calendar. And here is my yield of what people do.</p>
<h2>Simulating a navigation list</h2>
<p>One of the first things I encountered was a painting tool that had a gallery of created graphics as a background. Now, to me this would be a simple list:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;{link}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;{src}&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;{title}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  [...]
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The markup I found though was this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;sky&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;skyTile&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;{calculated styles};display:block&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;skyThumb&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;{src}&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;{generated styles}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;images/thumb_dropShadow.png&quot;</span> </span>
<span style="color: #009900;">         <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;skyThumbShadow&quot;</span> </span>
<span style="color: #009900;">         <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;{generated styles}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  [...]
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This, of course is generated by the backend. My first gripe is the dropshadow image, after all this is an HTML5 showcase &#8211; just use CSS3. We also have the three instances of generated styles and double classes. Granted, an extra class gives you a handle to all images instead of tiles, so why not. But as there is no real link around the image, the click handler has to read the url from somewhere. There is a lot of unnecessary back and forth between DOM and scripting here which does slow down the whole demo. Seeing that this is also the main navigation from the entry page to the editor this could be a list inside a <a href="http://www.w3.org/TR/html5/sections.html#the-nav-element"><code>nav</code></a> element. A list groups these items together, a bunch of DIVs doesn&#8217;t (screen readers for example tell you how many items there are in a list). </p>
<p>Another list I found was supposed to be links to refresh the app and have a hierarchy but instead was a flat list with classes to define hierarchy and group:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mitems&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;hedtop&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Simple<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mol&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{name}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  [... repeated ...]
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;hed&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{parent name}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mol&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{name}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  [... repeated ...]
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This could be OK, granted you also shift keyboard focus, but why not:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nav<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mitems&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>{parent name}
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;{url}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{name}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      [... repeated ...]
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  [... repeated ...]
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nav<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This would give you styling hooks and functionality for free. Links and buttons are great to trigger functionality &#8211; but it seems that is too easy.</p>
<h2>Click (probably) here for functionality</h2>
<p>If I build a button for an application to trigger a certain functionality this is the markup:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;button</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;edit&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Edit<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/button<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><a href="http://www.w3.org/TR/html5/the-button-element.html#the-button-element">Buttons</a> are what trigger functionality &#8211; both a backend script or a JavaScript. They are keyboard accessible, have a disabled state and sensible out-of-the-box styling that nowadays can be completely overwritten. The class can be the definition of what the button should do &#8211; instead of the text which will change. You could use an ID but a class allows to repeat buttons (for example on the top and the bottom of a results list).</p>
<p>The buttons I found though were slightly different:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;homeButtonPanel&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;homeButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;drawHomeButton&quot;</span> </span>
<span style="color: #009900;">       <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: block;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Start Drawing<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;homeButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;viewHomeButton&quot;</span> </span>
<span style="color: #009900;">       <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: block;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>View the Mural<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;controlPanel&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: block;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;titleButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>{title}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainMenu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainButton mainSelected&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;drawButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Draw<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;inkDisplay&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;inkMeter&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;width: 94px;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuContainer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuButton drawMenuButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;behaviorsButton&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: block; opacity: 1;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Gesture<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Behaviors<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuContainer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuButton drawMenuButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;artworkButton&quot;</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: block; opacity: 1;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Artwork<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuContainer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuButton drawMenuButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;resetButton&quot;</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: block; opacity: 1;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Reset<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuContainer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuButton drawMenuButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;undoButton&quot;</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: block; opacity: 1;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Undo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuContainer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menuButton drawMenuButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;saveButton&quot;</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: block; opacity: 1;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Save<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainMenu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;viewButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>View<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainMenu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;secondaryButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;helpButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Help<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainMenu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainShare shareButtonSmall&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mainTwitterButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;twitter&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;images/twitter_icon.png&quot;</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;opacity: 0.6;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainShare shareButtonLarge&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mainFacebookButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;facebook&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;images/facebook_icon.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mainShare shareButtonSmall&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mainEmailButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;images/email_icon.png&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;opacity: 0.6;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>So instead of using a nested list with classes for each button and the hierarchy in the nesting we have a lot of classes and a hand-rolled DIV construct. Instead of making buttons really disabled we rely on opacity and there is quite a mix of inline images and background images (if all were background images, they could be one sprite!). Keyboard navigation will have to be written for this and if you were to add a button you&#8217;d have to come up with another ID.</p>
<p>HTML5 actually has a construct for this. There is a <a href="http://www.w3.org/TR/html5/interactive-elements.html#menus"><code>menu</code></a> element with <a href="http://www.w3.org/TR/html5/interactive-elements.html#the-command">command</a> child elements. These are in use in Chrome&#8217;s side bar for example and should be what we use. If you want to make it work for everyone, a nested list with <code>button</code> elements is what to go for.</p>
<p>The overly complex DIV construct is quite used though &#8211; this was another example:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;uiScreen&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;startScreen&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;panelBackground&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mainResumeButton&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: none;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;largeUIButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;resumeButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Resume Game<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;panelBackground&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mainStartButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;largeUIButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;startButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Start Game<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>		
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;panelBackground&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mainHelpButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;largeUIButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;helpButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Help<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;panelBackground&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mainHighscoreButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;largeUIButton&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;highscoreButton&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>High Scores<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>When in doubt &#8211; add an ID and class to everything.</p>
<p>Other buttons I encountered were actually links pointing to <code>javascript://</code> using an inline style to indicate hierarchy:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;navlist&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;play&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript://&quot;</span> </span>
<span style="color: #009900;">         <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;display: inline;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Play<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pause&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript://&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Pause<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;padding-left: 2px;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Effects:<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;bw&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript://&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Bw<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;outline&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript://&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Outline<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;color&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript://&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Color<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;invert&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript://&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Invert<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;matrix&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript://&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Matrix<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;old&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript://&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Old<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Talking of inline &#8211; here&#8217;s a great example of a tool generating a lot of code that could be replaced by a single event handler and <a href="http://icant.co.uk/sandbox/eventdelegation/">event delegation</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;tools&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">onmouseout</span>=<span style="color: #ff0000;">&quot;buttonOut(1)&quot;</span> <span style="color: #000066;">onmouseover</span>=<span style="color: #ff0000;">&quot;buttonOver(1)&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">onclick</span>=<span style="color: #ff0000;">&quot;buttonClicked(1)&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;button1&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;image/button/1.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">onmouseout</span>=<span style="color: #ff0000;">&quot;buttonOut(2)&quot;</span> <span style="color: #000066;">onmouseover</span>=<span style="color: #ff0000;">&quot;buttonOver(2)&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">onclick</span>=<span style="color: #ff0000;">&quot;buttonClicked(2)&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;button2&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;image/button/2.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  [...repeated 20 times...]
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;toolsSeparator&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;toolbarButtonSave&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;toolbarButton&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript:saveCanvas()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;image/save.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;New&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;toolbarButtonNew&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;toolbarButton&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript:newCanvas()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;New&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;image/new.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #808080; font-style: italic;">&lt;!--[if !IE]&gt;&lt;![IGNORE[--&gt;&lt;!--[IGNORE[]]--&gt;</span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;toolbarButtonMenu&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;toolbarButton&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">onmouseout</span>=<span style="color: #ff0000;">&quot;closeMenuDelay()&quot;</span> <span style="color: #000066;">onmouseover</span>=<span style="color: #ff0000;">&quot;showMenuHover()&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript:showMenu()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&amp;gt;&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;image/menu.png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">onmouseout</span>=<span style="color: #ff0000;">&quot;closeMenuDelay()&quot;</span> <span style="color: #000066;">onmouseover</span>=<span style="color: #ff0000;">&quot;overMenu()&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;menu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;saveMenu&quot;</span> <span style="color: #000066;">onmouseout</span>=<span style="color: #ff0000;">&quot;closeMenuDelay()&quot;</span> </span>
<span style="color: #009900;">       <span style="color: #000066;">onmouseover</span>=<span style="color: #ff0000;">&quot;overMenu()&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript:saveCanvas()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      save normal
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;saveMenu&quot;</span> <span style="color: #000066;">onmouseout</span>=<span style="color: #ff0000;">&quot;closeMenuDelay()&quot;</span> </span>
<span style="color: #009900;">       <span style="color: #000066;">onmouseover</span>=<span style="color: #ff0000;">&quot;overMenu()&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript:saveCanvasHi()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      save high quality
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;footnote&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #ddbb00;">&amp;nbsp;</span> (rename to *.png)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">onmouseout</span>=<span style="color: #ff0000;">&quot;closeMenuDelay()&quot;</span> <span style="color: #000066;">onmouseover</span>=<span style="color: #ff0000;">&quot;overMenu()&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;javascript:showAbout()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      about...
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;lastMenu&quot;</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;_top&quot;</span> <span style="color: #000066;">onmouseout</span>=<span style="color: #ff0000;">&quot;closeMenuDelay()&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">onmouseover</span>=<span style="color: #ff0000;">&quot;overMenu()&quot;</span> </span>
<span style="color: #009900;">       <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;{url}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;footnote&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;em<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>elsewhere:<span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/em<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;em<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a sound memory game<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/em<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #808080; font-style: italic;">&lt;!--&lt;![endif]--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Notice that if the images for the button couldn&#8217;t be loaded for one reason or another (or you can&#8217;t see them at all) this application is very confusing indeed &#8211; no alternative text for the images and no text content to fall back to. I am also very much sure that the in and out handlers trigger visual effects CSS could handle better.</p>
<h2>Reasons and effects</h2>
<p>I know there are probably good reasons for all of this, and I am sure I will also do things wrongly when I am rushed or want to get things out quickly. What we have to understand though is that right now we have a responsibility to show the best of breed demos we can. </p>
<p>We cannot preach the open web and technologies and view-source over closed systems and at the same time forget the things we learnt in the last decade. Some of these things I found look like code Frontpage or Dreamweaver could have produced in the 90ies and resulted in a lot of badly performing, hard to maintain products that either still annoy people who have to use them or get replaced every 2 years.</p>
<p>We have a mandate to educate the new developers coming to the web. Unlearning something is much harder than learning it &#8211; so let&#8217;s not start with bloat and quick fixes that work but forget to advocate clean code and thinking about the impact your product has on the end users (thinking accessibility) and the poor sods that will have to maintain your product when you are gone. We are not here to advocate effects and products, we are here to promote the tools that allow anyone to easily build something cool that is also easy to understand. </p>
<p>HTML5 is about evolving the web as a platform &#8211; we also need to evolve with it and take more responsibility. We have app and we have markup enthusiasts. Let&#8217;s make them work together to build things that are great functionality and clean semantics.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/12/a-call-for-quality-html5-demo-markup/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Delivering the good message of local storage</title>
		<link>http://hacks.mozilla.org/2010/12/delivering-the-good-message-of-local-storage/</link>
		<comments>http://hacks.mozilla.org/2010/12/delivering-the-good-message-of-local-storage/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 01:21:03 +0000</pubDate>
		<dc:creator>Chris Heilmann</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Firefox 3.5]]></category>
		<category><![CDATA[Firefox 3.6]]></category>
		<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[local storage]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=6770</guid>
		<description><![CDATA[As you might know there are an incredible amount of advent calendar blogs out at the moment each delivering one cool article for each day of December until Christmas. Today (6/12/11) two calendar blogs delivered an article of mine talking about the benefits of using local storage in browsers and how to implement it. You [...]]]></description>
			<content:encoded><![CDATA[<p>As you might know there are an incredible amount of advent calendar blogs out at the moment each delivering one cool article for each day of December until Christmas. </p>
<p>Today (6/12/11) two calendar blogs delivered an article of mine talking about the benefits of using local storage in browsers and how to implement it.</p>
<p>You can find <a href="http://24ways.org/2010/html5-local-storage">the English version on the 24ways.org calendar</a> and <a href="http://www.webkrauts.de/2010/12/06/html5-als-geschenkverpackung-von-daten/">a German translation at the Webkrauts calendar</a>.</p>
<p>In essence, the article explains why it is a good idea to use local storage, explains how to use it, how to work around the issue that local storage can only store strings and gives example code on how to speed up web service use by caching information client-side much like you would do it on a server.</p>
<p>Have a read and go speed up your own solutions by using what browsers provide you these days. </p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/12/delivering-the-good-message-of-local-storage/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Firefox 4: HTML5 Forms</title>
		<link>http://hacks.mozilla.org/2010/11/firefox-4-html5-forms/</link>
		<comments>http://hacks.mozilla.org/2010/11/firefox-4-html5-forms/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 16:00:46 +0000</pubDate>
		<dc:creator>Anthony Ricaud</dc:creator>
				<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5821</guid>
		<description><![CDATA[Firefox 4 will come with better support for HTML5 forms. In the latest beta we are experimenting with a set of new features: more inputs types (email, url, tel, search), new attributes (placeholder, autofocus, list), decoupled forms and different validation mechanisms. This is thanks mostly to the hard work of Mounir Lamouri. Some examples will [...]]]></description>
			<content:encoded><![CDATA[<p><em>Firefox 4 will come with better support for HTML5 forms. In the latest beta we are experimenting with a set of new features: more inputs types (email, url, tel, search), new attributes (placeholder, autofocus, list), decoupled forms and different validation mechanisms. This is thanks mostly to the hard work of Mounir Lamouri.</em></p>
<p><em>Some examples will work in other browsers, but you&#8217;ll need Firefox 4 beta to see all of them.</em></p>
<h2>New input field types</h2>
<p>In the same fashion as new HTML5 elements, we have new field types to better express what kind of input we want.  The look and feel of many of these elements is the same as a text field, but they carry a different semantic meaning.  This means that browsers can optimize the experience for users.  For example, a mobile browser can provide a specific keyboard for a field.  Or the browser can pre-fill phone number fields based on people in your address book.  And extensions may even provide some features based on those types.</p>
<p>In this beta, Firefox comes with four new kind of inputs :</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;search&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;tel&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;url&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;email&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>Of the four new input types, <code>url</code> and <code>email</code> will also validate their content.  We&#8217;ll talk about that later.</p>
<p>We also have support for a new kind of field:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;output</span> <span style="color: #000066;">for</span>=<span style="color: #ff0000;">&quot;i1 i2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>You can use this element to represent an area of the page that reacts to the interaction with a form. Think about the total price in a cart after you&#8217;ve changed the quantity of items or the shipping options. It won&#8217;t compute anything, you&#8217;ll need to do that with JavaScript, but it will give hints to accessibility technologies. The <code>for</code> attribute is a list of IDs of the fields that intervene into the calculation.</p>
<p>Text fields have been improved with <code>&lt;datalist&gt;</code> support. You can easily provide a list of suggestions for a field as the user is typing. You bind the field and the datalist by using the <code>list</code> attribute. It will use every <code>option</code> element inside <code>datalist</code> to populate the list. And for browsers without <code>datalist</code> support, they will display the content of the <code>datalist</code> element. So be sure to provide some valid markup to get a nice fallback.</p>
<p><label>Enter a city:<br />
<input list="cities"></label><br />
<datalist id="cities"> or <label>choose one<br />
<select>
<option value="Paris">Paris</option>
<option value="London">London</option>
<option value="Berlin">Berlin</option>
<option value="New York">New York</option>
<option value="Tokyo">Tokyo</option>
<option value="Sydney">Sydney</option>
<option value="Johannesburg">Johannesburg</option>
</select>
<p> </label> </datalist></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Enter a city: <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">list</span>=<span style="color: #ff0000;">&quot;cities&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;datalist</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;cities&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  or
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>choose one
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;select<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;option</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Paris&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Paris<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;option</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;London&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>London<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;option</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Berlin&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Berlin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;option</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;New York&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>New York<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;option</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Tokyo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Tokyo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;option</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Sydney&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Sydney<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;option</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Johannesburg&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Johannesburg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/select<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/datalist<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>New input attributes</h2>
<h3>Autofocus</h3>
<p>When you add this to a field, it will receive focus as soon as possible. The direct advantage for the user is that all sites will have the same algorithm for autofocus instead of relying on different JavaScript code. And browsers or extensions could disable this behavior if a user is not interested in it.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> autofocus<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<h3>Placeholder</h3>
<p>The value of this attribute will be displayed inside the form when it is empty and not focused. You can put an example of the kind of expected value.</p>
<style>
#placeholders label {display: block;}
</style>
<form id="placeholders">
<label>Telephone:</label><br />
<input placeholder="1-800-555-1234">
<label>Comments:</label><textarea id="buggy-textarea" placeholder="Tell us what you think about our service…"><!-- Don't break planet.mozilla.org --></textarea><br />
</form>
<p><script>
// Something is transforming <textarea></textarea> into <textarea/> so working around that :(
document.getElementById("buggy-textarea").value = "";
</script></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Telephone: <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">placeholder</span>=<span style="color: #ff0000;">&quot;1-800-555-1234&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Comments: <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;textarea</span> <span style="color: #000066;">placeholder</span>=<span style="color: #ff0000;">&quot;Tell us what you think about our service…&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/textarea<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Decoupled forms</h2>
<p>You have more options to define the interaction between fields and forms.</p>
<h3>form attribute</h3>
<p><strong>&lt;input&gt; elements don&#8217;t need to be children of a &lt;form&gt; element anymore.</strong> You can define them anywhere you want and bind them to a form using the new <code>form</code> attribute. It takes the ID of the form it should bind to.</p>
<p>Here&#8217;s an example.  Let&#8217;s say you&#8217;re working on a search engine for some blogging software. You want a very simple form for the general use case and some advanced options if the user needs more control. </p>
<p>At the top of the page you could put:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;search&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;search_field&quot;</span> <span style="color: #000066;">form</span>=<span style="color: #ff0000;">&quot;search_form&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>And at the bottom:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;form</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;search_form&quot;</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;search.php&quot;</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;post&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fieldset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;legend<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Advanced options<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/legend<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;checkbox&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Private posts
    <span style="color: #808080; font-style: italic;">&lt;!-- Other options --&gt;</span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fieldset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This will behave as if the search field was part of the form. And you get the freedom of placing it wherever you want in your HTML.</p>
<h3>Form options on fields</h3>
<p>All the options that can be defined at the form level can be overridden at the field element. All submit fields (&lt;button&gt; and input type=&#8221;submit&#8221;) accept four new attributes : <strong>formenctype</strong>, <strong>formaction</strong>, <strong>formmethod</strong> and <strong>formtarget</strong>.</p>
<p>One use case could be a form with a preview and post buttons. Each one needs all the fields of the form but they perform a different action.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;form</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;new_post.php&quot;</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;post&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Title: <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Content: <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;textarea<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/textarea<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">formaction</span>=<span style="color: #ff0000;">&quot;preview.php&quot;</span> <span style="color: #000066;">formmethod</span>=<span style="color: #ff0000;">&quot;get&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Preview&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Post&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>When the user clicks on the Preview button, its attributes will override the form&#8217;s attributes. In this case, instead of a POST request to new_post.php, the whole form will be sent to the preview.php script with a GET method.</p>
<h2>Validation mechanisms</h2>
<p>One of the big area of improvements for forms is validation. To give the best experience, we need to give feedback as soon as possible to the user. So people have written a lot of JavaScript code to do that. Wouldn&#8217;t it be nicer if browsers handled that?</p>
<h3>required</h3>
<p>By adding this attribute, you&#8217;ll mark this field as required. For text fields, it means that it shouldn&#8217;t be left empty. For checkbox buttons, it means it should be checked. And for radio buttons, it means one of the button for a group should be selected.</p>
<p>Try each of the examples below and you&#8217;ll see that they change color when you interact with them.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text&quot;</span> required<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p></p>
<input type="text" required>
</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;checkbox&quot;</span> required<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<input type="checkbox" required>
</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;radiogroup&quot;</span> required<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;radiogroup&quot;</span> required<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;radiogroup&quot;</span> required<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<input type="radio" name="radiogroup" required>
<input type="radio" name="radiogroup" required>
<input type="radio" name="radiogroup" required>
</p>
<h3>url</h3>
<p>URL fields are automatically validated.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;mozilla&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://mozilla.org&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<input type="url" value="mozilla">
<input type="url" value="http://mozilla.org">
</p>
<h3>email</h3>
<p>Emails are also automatically validated. By passing the multiple attribute (<a href="http://hacks.mozilla.org/2009/12/multiple-file-input-in-firefox-3-6/">also valid on type=&#8221;file&#8221;</a>), you can also validate a list of mails separated by commas.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;foo@bar.org&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<input type="email" value="foo">
<input type="email" value="foo@bar.org">
</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;email&quot;</span> multiple <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;foo@bar.org, spongebob&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;email&quot;</span> multiple <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;foo@bar.org, spongebob@squarepants.org&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<input type="email" multiple value="foo@bar.org, spongebob">
<input type="email" multiple value="foo@bar.org, spongebob@squarepants.org">
</p>
<h3>pattern</h3>
<p>Urls and emails will not be the only type of data you&#8217;ll want to validate. Therefore, the pattern attribute will allow you to provide a JavaScript regular expression. This will be matched against the value of the field to determine if it&#8217;s valid. You should also provide a title attribute explaining the pattern to the user.</p>
<p>In the example below, try hovering over the text field.  You should see a popup that tells you how to fill out the form.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;[0-9][A-Z]{3}&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;A part number is a digit followed by three uppercase letters.&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<input pattern="[0-9][A-Z]{3}" title="A part number is a digit followed by three uppercase letters.">
</p>
<h3>The constraint validation API</h3>
<p>If you need even more control over the validation, you can use the <code>setCustomValidity</code> method. If you provide an empty string to this method, the element will be considered valid. Otherwise, it will be marked as invalid and the string will be used as a tooltip to help your user understand the problem.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Password: <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;password1&quot;</span> <span style="color: #000066;">oninput</span>=<span style="color: #ff0000;">&quot;checkPasswords()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Confirm password: <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;password2&quot;</span> <span style="color: #000066;">oninput</span>=<span style="color: #ff0000;">&quot;checkPasswords()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
function checkPasswords() {
  var password1 = document.getElementById('password1');
  var password2 = document.getElementById('password2');
  if (password1.value != password2.value) {
    password2.setCustomValidity('Passwords should match');
  } else {
    password2.setCustomValidity('');
  }
}
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><label>Password:<br />
<input type="password" id="password1" oninput="checkPasswords()"></label><br />
<label>Confirm password:<br />
<input type="password" id="password2" oninput="checkPasswords()"></label><br />
<script>
function checkPasswords() {
  var password1 = document.getElementById('password1');
  var password2 = document.getElementById('password2');
  if (password1.value != password2.value) {
    password2.setCustomValidity('Passwords should match.');
  } else {
    password2.setCustomValidity('');
  }
}
</script></p>
<p>If one of the field of a form is not valid, then submitting the form will be blocked and the first invalid field will be focused with a message explaining the problem. If you want to override this behaviour and send the form anyway, you can add a <code>novalidate</code> attribute on the form or the <code>formnovalidate</code> attribute on the appropriate submit button.</p>
<p>If you want more details on the validation mechanisms, check out <a href="http://blog.oldworld.fr/index.php?post/2010/11/17/HTML5-Forms-Validation-in-Firefox-4">Mounir&#8217;s blog post</a>.</p>
<h2>New CSS selectors</h2>
<p>And to go with all this goodness are a few new CSS selectors.</p>
<h3><code>:required</code>, <code>:optional</code></h3>
<p>All fields are marked as <code>:optional</code> by default. If they have the required attribute, they&#8217;ll match the <code>:required</code> pseudo-class instead.</p>
<h3><code>:valid</code>, <code>:invalid</code></h3>
<p>These pseudo-classes represent the state of the field regarding validation. You can use <code>:invalid</code> to override the default styling that Firefox 4 provides.</p>
<p>Here&#8217;s an example of a text box where the default style has been overridden.</p>
<style>
#selectors :optional {
  border: 1px solid black;
}
#selectors :required {</p>
<p>}
#selectors :invalid {
  -moz-box-shadow: none;
  box-shadow: none;
  border: 1px solid red;
}
#selectors :valid {
  background: #ddffdd;
}
</style>
<form id="selectors">
<input required>
<input type="checkbox">
</form>
<p></p>
<h3><code>:-moz-placeholder</code></h3>
<p>This pseudo-class targets input fields displaying a placeholder. This is not yet part of CSS, so you&#8217;ll need to use a pseudo-element for WebKit based browsers.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
#selectors2 :-moz-placeholder {
  font-style: italic;
}
#selectors2 ::-webkit-placeholder {
  font-style: italic;
}
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;form</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;selectors2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">placeholder</span>=<span style="color: #ff0000;">&quot;Style me&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<style>
#selectors2 :-moz-placeholder {
  font-style: italic;
}
#selectors2 ::-webkit-placeholder {
  font-style: italic;
}
</style>
<form id="selectors2">
<input placeholder="Style me">
</form>
<p></p>
<h2>Conclusion</h2>
<p>Form features in HTML5 are very new, and there&#8217;s still a wide difference between browsers. Opera implemented part of the spec (it was called Webforms2 at that time) so it has decent support for HTML5 Forms, along with some quirks since the spec evolved since that implementation. WebKit-based browsers are currently implementing some parts of the spec so you&#8217;ll also find some early support there as well.</p>
<p>We will not be adding more form features in Firefox 4, and there is clearly still some work to get full support for HTML5 forms. New field types (numbers, colors, dates), new attributes (step, min, max), new events (onforminput, onformchange) and so on.  We&#8217;ll be adding support for more of HTML5 forms in later releases.</p>
<p>This was just a rough introduction. To get all the details, you should go to the <a href="https://developer.mozilla.org/en/HTML/HTML5/Forms_in_HTML5">documentation on Mozilla Developer Network</a>.</p>
<style>
h1, h2, h3 {
margin-bottom: 15px;
}
</style>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/11/firefox-4-html5-forms/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>HTML5 Video preload attribute supported in Firefox 4, autobuffer attribute removed</title>
		<link>http://hacks.mozilla.org/2010/08/video_preload_attribute/</link>
		<comments>http://hacks.mozilla.org/2010/08/video_preload_attribute/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 14:22:49 +0000</pubDate>
		<dc:creator>Paul Rouget</dc:creator>
				<category><![CDATA[Audio]]></category>
		<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5673</guid>
		<description><![CDATA[This is a re-post from Chris Pearce’s blog. To comply with the HTML5 specification, we replaced the autobuffer attribute with the tri-state preload attribute. We encourage you to update your code. See the documention on MDC. Late last week I landed support on Firefox trunk for the HTML5 video &#8216;preload&#8217; attribute. This replaces the &#8216;autobuffer&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a re-post from <a href="http://blog.pearce.org.nz/2010/08/html4-video-preload-attribute-supported.html">Chris Pearce’s blog</a>. To comply with the HTML5 specification, we replaced the <code>autobuffer</code> attribute with the tri-state <code>preload</code> attribute. We encourage you to update your code. See the <a href="https://developer.mozilla.org/En/HTML/Element/Video#Attributes">documention on MDC</a>.</em></p>
<p>Late last week I landed support on Firefox trunk for the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#attr-media-preload">HTML5 video &#8216;preload&#8217; attribute</a>. This replaces the &#8216;autobuffer&#8217; attribute, which we previously supported. If you were previously using the autobuffer attribute on your HTLM5 videos, you need to update to using the preload attribute as well.</p>
<p>The preload attribute provides a hint to the browser as to how much downloading is sensible for a given media. The preload attribute can have three values:</p>
<ol>
<li>&#8220;<b>none</b>&#8221; &#8211; suggests to the browser that it doesn&#8217;t need to load this media at all until the user plays the resource. The browser will delay any network traffic required to load the media until the users tries to play the resource, or explicitly loads the resource. I suggest using this preload value, along with the poster attribute, when it&#8217;s unlikely that the user will play the resource. This is probably most useful in a mobile environment, where data can be expensive.</li>
<li>&#8220;<b>metadata</b>&#8221; &#8211; suggests to the browser that it isn&#8217;t necessary to load the entire resource in advance. The browser will suspend the load after loading metadata, displaying the first video frame (if there&#8217;s no poster image), and ensuring it can play the media. This is the default behaviour, and prevents excess network traffic when the web developer isn&#8217;t certain the video will definitely be played. If you don&#8217;t specify a preload value, Firefox will automatically do this. This was also the default behaviour in Firefox 3.5 and 3.6 in the absence of the autobuffer attribute. This default behaviour is a suitable compromise between bandwidth saving and user convenience.</li>
<li>&#8220;<b>auto</b>&#8221; &#8211; suggests to the browser that it should load as much of the resource as possible. As long as the browser&#8217;s own media cache isn&#8217;t full, it will keep on downloading. I suggest this is most useful in the &#8220;YouTube&#8221; case, when you&#8217;ve got a media which the user is almost certainly going to watch, and so having the user download the media is not likely to be wasting server bandwidth. This behaviour is the same as using the autobuffer attribute in Firefox 3.5 and 3.6</li>
</ol>
<p>Since the autobuffer attribute is no longer present in Firefox 4, and the preload attribute is not present in Firefox 3.5 and 3.6, <b>if you want a media to download completely, you should include both preload=&#8221;auto&#8221; and autobuffer in the video element</b>, <i>e.g.</i>:</p>
<p><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&lt;video autobuffer preload=&#8221;auto&#8221; src=&#8221;video.ogg&#8221;&gt;&lt;/video&gt;</span></p>
<p><b>If you want the video to only be downloaded if the user actually plays the video, you should not include either the preload or the autobuffer attribute.</b> The default behaviour in Firefox 3.5, 3.6, and the upcoming Firefox 4 is to only load up to the first frame and then suspend the download.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/08/video_preload_attribute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox 4: An early walk-through of IndexedDB</title>
		<link>http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/</link>
		<comments>http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 18:43:26 +0000</pubDate>
		<dc:creator>Arun Ranganathan</dc:creator>
				<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[IndexedDB]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4857</guid>
		<description><![CDATA[Web developers already have localStorage, which is used for client side storage of simple key-value pairs. This alone doesn&#8217;t address the needs of many web applications for structured storage and indexed data. Mozilla is working on a structured storage API with indexing support called IndexedDB, and we will have some test builds in the next [...]]]></description>
			<content:encoded><![CDATA[<p>Web developers already have <a href="https://developer.mozilla.org/en/DOM/Storage">localStorage</a>, which is used for client side storage of simple key-value pairs.  This alone doesn&#8217;t address the needs of many web applications for structured storage and indexed data.  Mozilla is working on a structured storage API with indexing support called <a href="http://dev.w3.org/2006/webapi/IndexedDB/">IndexedDB</a>, and we will have some test builds in the next few weeks.  This can be compared to the <a href="http://dev.w3.org/html5/webdatabase/">WebDatabase API</a> implemented by several browsers that uses a subset of the allowable language of <a href="http://www.sqlite.org/">SQLite</a>.  Mozilla has chosen to not implement WebDatabase for <a href="http://hacks.mozilla.org/2010/06/beyond-html5-database-apis-and-the-road-to-indexeddb">various reasons discussed in this post</a>.</p>
<p>In order to compare IndexedDB and WebDatabase, we are going to show four examples that use most parts of the asynchronous APIs of each specification.  The differences between SQL storage with tables (WebDatabase) and JavaScript object storage with indexes (IndexedDB) becomes pretty clear after reading the examples.  The synchronous versions of these APIs are only available on worker threads.  Since not all browsers currently implement worker threads, the synchronous APIs will not be discussed at this time.  The IndexedDB code is based off a <a href="http://lists.w3.org/Archives/Public/public-webapps/2010AprJun/0717.html">proposal that Mozilla has submitted to the W3C WebApps working group</a> that has gotten positive feedback so far.  The code for both APIs does not include any error handling (for brevity), but production code should always have it!</p>
<p>These examples are for the storage of a candy store&#8217;s sale of candy to customers, which we&#8217;ll refer to as kids.  Each entry in <code>candySales</code> represents a sale of a specified amount of candy to a kid, specified by an entry in <code>candy</code> and <code>kids</code> respectively.</p>
<h3>Example 1 – Opening and Setting Up a Database</h3>
<p>This first example demonstrates how to open a database connection and create the tables or object stores if the version number is not correct.  Upon opening the database, both examples check the version and create the necessary tables or object stores and then set the correct version number.  WebDatabase is a bit stricter in how it handles versions by giving an error if the database version is not what the caller expects (this is specified by the second argument to openDatabase).  IndexedDB simply lets the caller handle versioning as they see fit.  Note that there is <a href="http://lists.w3.org/Archives/Public/public-webapps/2010AprJun/thread.html#msg611">active discussion about how IndexedDB should handle version changes</a> in the working group.</p>
<p><strong>WebDatabase</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> db <span style="color: #339933;">=</span> window.<span style="color: #660066;">openDatabase</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CandyDB&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #3366CC;">&quot;My candy store database&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #CC0000;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>db.<span style="color: #660066;">version</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  db.<span style="color: #660066;">changeVersion</span><span style="color: #009900;">&#40;</span>db.<span style="color: #660066;">version</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// User's first visit.  Initialize database.</span>
    <span style="color: #003366; font-weight: bold;">var</span> tables <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
      <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;kids&quot;</span><span style="color: #339933;">,</span> columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;id INTEGER PRIMARY KEY&quot;</span><span style="color: #339933;">,</span>
                                <span style="color: #3366CC;">&quot;name TEXT&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;candy&quot;</span><span style="color: #339933;">,</span> columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;id INTEGER PRIMARY KEY&quot;</span><span style="color: #339933;">,</span>
                                 <span style="color: #3366CC;">&quot;name TEXT&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;candySales&quot;</span><span style="color: #339933;">,</span> columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;kidId INTEGER&quot;</span><span style="color: #339933;">,</span>
                                      <span style="color: #3366CC;">&quot;candyId INTEGER&quot;</span><span style="color: #339933;">,</span>
                                      <span style="color: #3366CC;">&quot;date TEXT&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> index <span style="color: #339933;">&lt;</span> tables.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> index<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> table <span style="color: #339933;">=</span> tables<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      tx.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CREATE TABLE &quot;</span> <span style="color: #339933;">+</span> table.<span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;(&quot;</span> <span style="color: #339933;">+</span>
                    table.<span style="color: #660066;">columns</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;);&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> loadData<span style="color: #009900;">&#40;</span>db<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// User has been here before, no initialization required.</span>
  loadData<span style="color: #009900;">&#40;</span>db<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>IndexedDB</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> window.<span style="color: #660066;">indexedDB</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CandyDB&quot;</span><span style="color: #339933;">,</span>
                                    <span style="color: #3366CC;">&quot;My candy store database&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
request.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> db <span style="color: #339933;">=</span> event.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>db.<span style="color: #660066;">version</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// User's first visit, initialize database.</span>
    <span style="color: #003366; font-weight: bold;">var</span> createdObjectStoreCount <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> objectStores <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
      <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;kids&quot;</span><span style="color: #339933;">,</span> keyPath<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span> autoIncrement<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;candy&quot;</span><span style="color: #339933;">,</span> keyPath<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span> autoIncrement<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;candySales&quot;</span><span style="color: #339933;">,</span> keyPath<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span> autoIncrement<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> objectStoreCreated<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span>createdObjectStoreCount <span style="color: #339933;">==</span> objectStores.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        db.<span style="color: #660066;">setVersion</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          loadData<span style="color: #009900;">&#40;</span>db<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> index <span style="color: #339933;">&lt;</span> objectStores.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> index<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> params <span style="color: #339933;">=</span> objectStores<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      request <span style="color: #339933;">=</span> db.<span style="color: #660066;">createObjectStore</span><span style="color: #009900;">&#40;</span>params.<span style="color: #000066;">name</span><span style="color: #339933;">,</span> params.<span style="color: #660066;">keyPath</span><span style="color: #339933;">,</span>
                                     params.<span style="color: #660066;">autoIncrement</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      request.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> objectStoreCreated<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// User has been here before, no initialization required.</span>
    loadData<span style="color: #009900;">&#40;</span>db<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Example 2 – Storing Kids in the Database</h3>
<p>This example stores several kids into the appropriate table or object store.  This example demonstrates one of the risks that have to be dealt with when using WebDatabase: SQL injection attacks.  In WebDatabase explicit transactions must be used, but in IndexedDB a transaction is provided automatically if only one object store is accessed.  Transaction locking is per-object store in IndexedDB.  Additionally, IndexedDB takes a JavaScript object to insert, whereas with WebDatabase callers must bind specific columns.  In both cases you get the insertion id in the callback.</p>
<p><strong>WebDatabase</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> kids <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Anna&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Betty&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Christine&quot;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> db <span style="color: #339933;">=</span> window.<span style="color: #660066;">openDatabase</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CandyDB&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #3366CC;">&quot;My candy store database&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #CC0000;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
db.<span style="color: #660066;">transaction</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> index <span style="color: #339933;">&lt;</span> kids.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> index<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> kid <span style="color: #339933;">=</span> kids<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    tx.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;INSERT INTO kids (name) VALUES (:name);&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>kid<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                  <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #339933;">,</span> results<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">textContent</span> <span style="color: #339933;">=</span>
          <span style="color: #3366CC;">&quot;Saved record for &quot;</span> <span style="color: #339933;">+</span> kid.<span style="color: #000066;">name</span> <span style="color: #339933;">+</span>
          <span style="color: #3366CC;">&quot; with id &quot;</span> <span style="color: #339933;">+</span> results.<span style="color: #660066;">insertId</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>IndexedDB</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> kids <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Anna&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Betty&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Christine&quot;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> window.<span style="color: #660066;">indexedDB</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CandyDB&quot;</span><span style="color: #339933;">,</span>
                                    <span style="color: #3366CC;">&quot;My candy store database&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
request.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> objectStore <span style="color: #339933;">=</span> event.<span style="color: #660066;">result</span>.<span style="color: #660066;">objectStore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;kids&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> index <span style="color: #339933;">&lt;</span> kids.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> index<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> kid <span style="color: #339933;">=</span> kids<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    objectStore.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>kid<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">textContent</span> <span style="color: #339933;">=</span>
        <span style="color: #3366CC;">&quot;Saved record for &quot;</span> <span style="color: #339933;">+</span> kid.<span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; with id &quot;</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Example 3 – List All Kids</h3>
<p>This example lists all of the kids stored in the <code>kids</code> table or the <code>kids</code> object store.  WebDatabase uses a result set object which will be passed to the callback method provided after all rows have been retrieved.  IndexedDB, on the other hand, passes a cursor to the event handler as results are retrieved.  Results should come back faster, as a result.  While not shown in this example, you can also stop iterating data with IndexedDB by simply not calling <code>cursor.continue()</code>.</p>
<p><strong>WebDatabase</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> db <span style="color: #339933;">=</span> window.<span style="color: #660066;">openDatabase</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CandyDB&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #3366CC;">&quot;My candy store database&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #CC0000;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
db.<span style="color: #660066;">readTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// Enumerate the entire table.</span>
  tx.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SELECT * FROM kids&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #339933;">,</span> results<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> rows <span style="color: #339933;">=</span> results.<span style="color: #660066;">rows</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> index <span style="color: #339933;">&lt;</span> rows.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> index<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #339933;">=</span> rows.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> element <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      element.<span style="color: #660066;">textContent</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #000066;">name</span><span style="color: #339933;">;</span>
      document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;kidList&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>IndexedDB</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> window.<span style="color: #660066;">indexedDB</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CandyDB&quot;</span><span style="color: #339933;">,</span>
                                    <span style="color: #3366CC;">&quot;My candy store database&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
request.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// Enumerate the entire object store.</span>
  request <span style="color: #339933;">=</span> event.<span style="color: #660066;">result</span>.<span style="color: #660066;">objectStore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;kids&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">openCursor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  request.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> cursor <span style="color: #339933;">=</span> event.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// If cursor is null then we've completed the enumeration.</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>cursor<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #003366; font-weight: bold;">var</span> element <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    element.<span style="color: #660066;">textContent</span> <span style="color: #339933;">=</span> cursor.<span style="color: #660066;">value</span>.<span style="color: #000066;">name</span><span style="color: #339933;">;</span>
    document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;kidList&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cursor.<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Example 4 – List Kids Who Bought Candy</h3>
<p>This example lists all the kids, and how much candy each kid purchased.  WebDatabase simply uses a LEFT JOIN query which makes this example very simple.  IndexedDB does not currently have an API specified for doing a join between different object stores.  As a result, the example opens a cursor to the <code>kids</code> object store and an object cursor on the <code>kidId</code> index on the <code>candySales</code> object store and performs the join manually.</p>
<p><strong>WebDatabase</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> db <span style="color: #339933;">=</span> window.<span style="color: #660066;">openDatabase</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CandyDB&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #3366CC;">&quot;My candy store database&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #CC0000;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
db.<span style="color: #660066;">readTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  tx.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SELECT name, COUNT(candySales.kidId) &quot;</span> <span style="color: #339933;">+</span>
                <span style="color: #3366CC;">&quot;FROM kids &quot;</span> <span style="color: #339933;">+</span>
                <span style="color: #3366CC;">&quot;LEFT JOIN candySales &quot;</span> <span style="color: #339933;">+</span>
                <span style="color: #3366CC;">&quot;ON kids.id = candySales.kidId &quot;</span> <span style="color: #339933;">+</span>
                <span style="color: #3366CC;">&quot;GROUP BY kids.id;&quot;</span><span style="color: #339933;">,</span>
                <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #339933;">,</span> results<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> display <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;purchaseList&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> rows <span style="color: #339933;">=</span> results.<span style="color: #660066;">rows</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> index <span style="color: #339933;">&lt;</span> rows.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> index<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #339933;">=</span> rows.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      display.<span style="color: #660066;">textContent</span> <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;, &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;bought &quot;</span> <span style="color: #339933;">+</span>
                             <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">count</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;pieces&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>IndexedDB</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">candyEaters <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> displayCandyEaters<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> display <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;purchaseList&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> candyEaters<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    display.<span style="color: #660066;">textContent</span> <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;, &quot;</span> <span style="color: #339933;">+</span> candyEaters<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;bought &quot;</span> <span style="color: #339933;">+</span>
                           candyEaters<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">count</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;pieces&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> window.<span style="color: #660066;">indexedDB</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CandyDB&quot;</span><span style="color: #339933;">,</span>
                                    <span style="color: #3366CC;">&quot;My candy store database&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
request.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> db <span style="color: #339933;">=</span> event.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> transaction <span style="color: #339933;">=</span> db.<span style="color: #660066;">transaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;kids&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;candySales&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  transaction.<span style="color: #660066;">oncomplete</span> <span style="color: #339933;">=</span> displayCandyEaters<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> kidCursor<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> saleCursor<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> salesLoaded <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> count<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> kidsStore <span style="color: #339933;">=</span> transaction.<span style="color: #660066;">objectStore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;kids&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  kidsStore.<span style="color: #660066;">openCursor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    kidCursor <span style="color: #339933;">=</span> event.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
    count <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
    attemptWalk<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">var</span> salesStore <span style="color: #339933;">=</span> transaction.<span style="color: #660066;">objectStore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;candySales&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> kidIndex <span style="color: #339933;">=</span> salesStore.<span style="color: #660066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;kidId&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  kidIndex.<span style="color: #660066;">openObjectCursor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onsuccess</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    saleCursor <span style="color: #339933;">=</span> event.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
    salesLoaded <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    attemptWalk<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">function</span> attemptWalk<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>kidCursor <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>salesLoaded<span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>saleCursor <span style="color: #339933;">&amp;&amp;</span> kidCursor.<span style="color: #660066;">value</span>.<span style="color: #660066;">id</span> <span style="color: #339933;">==</span> saleCursor.<span style="color: #660066;">kidId</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      count<span style="color: #339933;">++;</span>
      saleCursor.<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      candyEaters.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> kidCursor.<span style="color: #660066;">value</span>.<span style="color: #000066;">name</span><span style="color: #339933;">,</span> count<span style="color: #339933;">:</span> count <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      kidCursor.<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>IndexedDB generally simplifies the programming model for interacting with databases, and allows for a wide number of use cases.  The working group is designing this API so it could be wrapped by JavaScript libraries; for instance, there&#8217;s plenty of room for a CouchDB-style API on top of our IndexedDB implementation.  It would also be very possible to build a SQL-based API on top of IndexedDB (such as WebDatabase).  Mozilla is eager to get developer feedback about IndexedDB, particularly since the specification has not been finalized yet.  Feel free to leave a comment here expressing your thoughts or <a href="https://rypple.com/sdwilsh/IndexedDB-feedback">leave anonymous feedback through Rypple</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/feed/</wfw:commentRss>
		<slash:comments>168</slash:comments>
		</item>
		<item>
		<title>Beyond HTML5: Database APIs and the Road to IndexedDB</title>
		<link>http://hacks.mozilla.org/2010/06/beyond-html5-database-apis-and-the-road-to-indexeddb/</link>
		<comments>http://hacks.mozilla.org/2010/06/beyond-html5-database-apis-and-the-road-to-indexeddb/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 18:43:00 +0000</pubDate>
		<dc:creator>Arun Ranganathan</dc:creator>
				<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[IndexedDB]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4898</guid>
		<description><![CDATA[IndexedDB is an evolving web standard for the storage of significant amounts of structured data in the browser and for high performance searches on this data using indexes. Mozilla has submitted substantial technical feedback on the specification, and we plan to implement it in Firefox 4. We spoke to prominent web developers about evolving an [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://dev.w3.org/2006/webapi/IndexedDB/">IndexedDB</a> is an evolving web standard for the storage of significant amounts of structured data in the browser and for high performance searches on this data using indexes. Mozilla has submitted <a href="http://lists.w3.org/Archives/Public/public-webapps/2010AprJun/0504.html">substantial technical feedback</a> on the specification, and we plan to implement it in Firefox 4.  We spoke to prominent web developers about evolving an elegant structured storage API for the web.  While versions of Safari, Chrome, and Opera support a technology called <a href="http://dev.w3.org/html5/webdatabase/">Web SQL Database</a>, which uses <a href="http://en.wikipedia.org/wiki/SQL">SQL</a> statements as string arguments passed to a JavaScript API, we think <em>developer aesthetics</em> are an important consideration, and that this is a particularly inelegant solution for client-side web applications.  We brought developer feedback to the <a href="http://blog.o-micron.com/">editor of the IndexedDB specification</a>, and also <a href="http://lists.w3.org/Archives/Public/public-webapps/2009OctDec/0449.html">spoke with Microsoft</a>, who agree with us that <a href="http://blogs.msdn.com/b/ie/archive/2010/03/09/working-with-the-html5-community.aspx">IndexedDB is a good option</a> for the web.  With additional <a href="http://www.chromium.org/developers/design-documents/indexeddb">implementations from the Chrome team</a> in the offing, we think it is worth explaining our design choices, and why we think IndexedDB is a better solution for the web than Web SQL Database.</p>
<p>Web applications can already take advantage of <a href="https://developer.mozilla.org/en/dom/storage"><code>localStorage</code> and <code>sessionStorage</code></a> in IE 8+, Safari 4+, Chrome 4+, Opera 10.5+ and Firefox 2+ to store key-value pairs with a simple JavaScript API.  <a href="http://dev.w3.org/html5/webstorage/">The Web Storage standard</a> (encompassing <code>localStorage</code> and <code>sessionStorage</code>), now widely implemented, is useful for storing <em>smaller</em> amounts of data, but less useful for storing <em>larger</em> amounts of <em>structured data</em>.  While many server-side databases use <a href="http://en.wikipedia.org/wiki/SQL">SQL</a> to programmatically store structured data and to meaningfully query  it, on the client-side, the use of SQL in a JavaScript API has been contentious.  </p>
<h3>SQL?  Which SQL?</h3>
<p>Many web developers certainly are familiar with <a href="http://en.wikipedia.org/wiki/SQL">SQL</a>, since many developers touch just as much server-side code (e.g. PHP and database operations) as client-side code (e.g. JavaScript, CSS, and markup).  However, despite the ubiquity that SQL enjoys, there isn&#8217;t a single normative SQL standard that defines the technology.  In particular, <a href="http://www.sqlite.org/">SQLite</a> supports most of <a href="http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt">SQL-92</a>, with some notable omissions, and is what the WebDatabase API is based on.  But SQLite itself isn&#8217;t a specification &#8212; it&#8217;s a release-ready technology!  And the best definition of what constitutes the supported subset of SQL that SQLite uses is <a href="http://www.sqlite.org/lang.html">the SQLite manual</a>.  In order to really get Web SQL Database right, we&#8217;d have to first start with defining a meaningful subset of SQL for web applications.  Why define a whole other language, when more elegant solutions exist within JavaScript itself?</p>
<h3>The Benefits and Pitfalls of SQLite</h3>
<p>We think SQLite is an extremely useful technology for applications, and make it available for <a href="https://developer.mozilla.org/en/Storage">Firefox extensions and trusted code</a>.  We don&#8217;t think it is the right basis for an API exposed to general web content, not least of all because there isn&#8217;t a credible, widely accepted standard that subsets SQL in a useful way.  Additionally, we don&#8217;t want changes to SQLite to affect the web later, and don&#8217;t think harnessing major browser releases (and a web standard) to SQLite is prudent.  IndexedDB does not have this problem; even though our underlying implementation of IndexedDB may be based on SQLite, we keep developers insulated from changes to SQLite by exposing an API that isn&#8217;t based on SQLite&#8217;s supported syntax.  </p>
<h3>Aesthetics and Web Developers</h3>
<p>Last year, we held a summit at the Mozilla campus to discuss storage on the web.  We invited web developers to speak to us about a desirable structured storage API on the web.  Many did express resigned acceptance of a SQLite-based API, since they had already experimented with releases of Web SQL Database in some browsers, and claimed that something in circulation was better than a collection of ideas. Yet, all voiced enthusiasm for better design choices, and how a simpler model would make life easier for them.  We watched as developers whiteboarded a simple <a href="http://en.wikipedia.org/wiki/B-tree">BTree</a> API that addressed their application storage needs, and this galvanized us to consider other options.  We were resolved that using strings representing SQL commands lacked the elegance of a &#8220;web native&#8221; JavaScript API, and started looking at alternatives.  Along with Microsoft, we sent  feedback about the IndexedDB proposal and actively became involved in the standardization effort.  </p>
<p>In another article, we <a href="http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase">compare IndexedDB with Web SQL Database</a>, and note that the former provides much syntactic simplicity over the latter.  IndexedDB leaves room for a third-party JavaScript library to straddle the underlying primitives with a BTree API, and we look forward to seeing initiatives like <a href="http://hg.toolness.com/browser-couch/raw-file/blog-post/index.html">BrowserCouch</a> built on top of IndexedDB.  Intrepid web developers can even build a SQL API on top of IndexedDB.  We&#8217;d <em>particularly welcome</em> an implementation of the Web SQL Database API <em>on top of</em> IndexedDB, since we think that this is technically feasible.  Starting with a SQL-based API for use with browser primitives wasn&#8217;t the right first step, but certainly there&#8217;s room for SQL-based APIs <em>on top</em> of IndexedDB.  </p>
<p>We want to continue the discussion with web developers about storage on the web, since that helps us structure our thoughts about product features and future web standards.  We look forward to seeing the next generation of web applications with support for high performance searches on indexed data, and to seeing web applications work even more robustly in &#8220;airplane mode.&#8221; </p>
<h3>Links</h3>
<ul>
<li><a href="http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/">A comparison of IndexedDB and the Web SQL Database API</a>.</li>
<li><a href="http://blog.vlad1.com/2009/04/06/html5-web-storage-and-sql/">Early objections to the Web SQL Database API voiced by Mozilla engineer Vladimir Vukicevic</a>.</li>
<li><a href="http://dev.w3.org/2006/webapi/IndexedDB/">IndexedDB specification</a>. </li>
<li><a href="https://developer.mozilla.org/en/dom/storage">MDC Documentation on localStorage</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/06/beyond-html5-database-apis-and-the-road-to-indexeddb/feed/</wfw:commentRss>
		<slash:comments>97</slash:comments>
		</item>
		<item>
		<title>upcoming changes to the viewport meta tag for firefox mobile</title>
		<link>http://hacks.mozilla.org/2010/05/upcoming-changes-to-the-viewport-meta-tag-for-firefox-mobile/</link>
		<comments>http://hacks.mozilla.org/2010/05/upcoming-changes-to-the-viewport-meta-tag-for-firefox-mobile/#comments</comments>
		<pubDate>Thu, 27 May 2010 16:59:03 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4952</guid>
		<description><![CDATA[This is a guest post by Matt Brubeck who works on the Firefox Mobile team. The upcoming release of Mobile Firefox (Fennec) 1.1 features improved support for the &#60;meta name="viewport"&#62; tag. Previous version of Fennec supported the width, height, and initial-scale viewport properties, but had problems with some sites designed for iPhone and Android browsers. [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a guest post by <a href="http://limpet.net/mbrubeck/">Matt Brubeck</a> who works on the Firefox Mobile team.</em></p>
<p>The upcoming release of <a href="https://wiki.mozilla.org/Mobile/Fennec">Mobile Firefox (Fennec)</a> 1.1 features improved<br />
support for the <code>&lt;meta name="viewport"&gt;</code> tag.  Previous version of Fennec supported the <code>width</code>, <code>height</code>, and <code>initial-scale</code> viewport properties, but had <a href="http://starkravingfinkle.org/blog/2010/01/perils-of-the-viewport-meta-tag/">problems</a> with some sites designed for iPhone and Android browsers. We now support the same properties Mobile Safari does, and we also changed Fennec to render mobile sites more consistently on screens of different sizes and resolutions.</p>
<p class="caption">touch.facebook.com before:</p>
<p class="figure"><img src="http://limpet.net/mbrubeck/images/2010/05-11-fennec-meta-viewport-2.png"></p>
<p class="caption">touch.facebook.com after:</p>
<p class="figure"><img src="http://limpet.net/mbrubeck/images/2010/05-11-fennec-meta-viewport-1.png"></p>
<p>You can see these changes for yourself in the latest <a href="http://ftp.mozilla.org/pub/mozilla.org/mobile/nightly/latest-mobile-1.9.2/">Fennec 1.1</a> and <a href="http://ftp.mozilla.org/pub/mozilla.org/mobile/nightly/latest-mobile-trunk/">trunk</a> nightly builds for Maemo, Android, Windows, Mac, or Linux.</p>
<h2>Background</h2>
<p>Mobile browers like Fennec render pages in a virtual &ldquo;window&rdquo; (the viewport), usually wider than the screen, so they don&#8217;t need to squeeze every page layout into a tiny window (which would break many non-mobile-optimized sites).  Users can pan and zoom to see different areas of the page.</p>
<p>Mobile Safari introduced the &ldquo;viewport meta tag&rdquo; to let web developers control the viewport&#8217;s size and scale.  Many other mobile browsers now support this tag, although it is not part of any web standard. Apple&#8217;s <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html#//apple_ref/doc/uid/TP40006509-SW29">documentation</a> does a good job explaining how web developers can use this tag, but we had to do some detective work to figure out exactly how to implement it in Fennec.  For example, Safari&#8217;s documentation says the content is a &ldquo;comma-delimited list,&rdquo; but existing browsers and web pages use any mix of commas, semicolons, and spaces as separators.</p>
<h2>Viewport basics</h2>
<p>A typical mobile-optimized site contains something like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span></span>
<span style="color: #009900;"> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width=device-width, initial-scale=1, maximum-scale=1&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>The <code>width</code> property controls the size of the viewport.  It can be set to a specific number of pixels like <code>width=600</code> or to the special value <code>device-width</code> value which is the width of the screen in CSS pixels at a scale of 100%.  (There are corresponding <code>height</code> and <code>device-height</code> values, which may be useful for pages with elements that change size or position based on the viewport height.)</p>
<p>The <code>initial-scale</code> property controls the zoom level when the page is first loaded.  The <code>maximum-scale</code>, <code>minimum-scale</code>, and <code>user-scalable</code> properties control how users are allowed to zoom the page in or out.</p>
<h2>A pixel is not a pixel</h2>
<p>The iPhone and many popular Android phones have 3- to 4-inch (7&ndash;10 cm) screens with 320×480 pixels (~160 dpi).  Firefox for Maemo runs on the Nokia N900, which has the same physical size but 480×800 pixels (~240 dpi).  Because of this, the last version of Fennec displayed many pages about one third smaller (in actual, physical size) than iPhone or Android.  This caused usability and readability problems on many touch-optimized web sites. Peter-Paul Koch wrote about this problem in <a href="http://www.quirksmode.org/blog/archives/2010/04/a_pixel_is_not.html">A pixel is not a pixel</a>.</p>
<p>Fennec 1.1 for Maemo will use 1.5 hardware pixels for each CSS &ldquo;pixel&rdquo;, following the lead of Android&#8217;s WebKit-based browser. This means a page with <code>initial-scale=1</code> will render at close to the same physical size in Fennec for Maemo, Mobile Safari for iPhone, and the Android Browser on both <a href="http://developer.android.com/guide/practices/screens_support.html#range">HDPI and MDPI</a> phones.  This is consistent with the <a href="http://www.w3.org/TR/CSS2/syndata.html#length-units">CSS 2.1 specification</a>, which says:</p>
<blockquote>
<p>If the pixel density of the output device is very different from that of a typical computer display, the user agent should rescale pixel values. It is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel. It is recommended that the reference pixel be the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm&#8217;s length.</p>
</blockquote>
<p>For web developers, this means that 320px be full width in portrait mode at scale=1, on all of the above-mentioned handheld devices, and they may size their layouts and images accordingly.  But remember that not all mobile devices are the same width; you should also make sure that your pages work well in landscape mode, and on larger devices like the iPad and Android tablets.</p>
<p>On 240-dpi screens, pages with <code>initial-scale=1</code> will effectively be zoomed to 150% by both Fennec and Android WebKit.  Their text will be smooth and crisp, but their bitmap images will probably not take advantage of the full screen resolution.  To get sharper images on these screens, web developers may want to design images &ndash; or whole layouts &ndash; at 150% of their final size (or 200%, to support the rumored 320-dpi iPhone) and then scale them down using CSS or viewport properties.</p>
<p>Right now Fennec uses the same default ratio of 1.5 on all devices. (It&#8217;s a hidden preference that can be changed in about:config or by an add-on.) Later we&#8217;ll need to change this &ndash; as well as many other parts of Fennec&#8217;s user interface &ndash; to work correctly on screens with different pixel densities.  Note that the default ratio of 1.5 is true only when the viewport scale equals 1.  Otherwise, the relationship between CSS pixels and device pixels depends on the current zoom level.</p>
<h2>Viewport width and screen width</h2>
<p>Many sites set their viewport to <code>"width=320, initial-scale=1"</code> to fit precisely onto the iPhone display in portrait mode.  As mentioned above, this caused <a href="http://starkravingfinkle.org/blog/2010/01/perils-of-the-viewport-meta-tag/">problems</a> when Fennec 1.0 endered these sites, especially in landscape mode.  To fix this, Fennec 1.1 will expand the viewport width if necessary to fill the screen at the requested scale.  This matches the behavior of Android and Mobile Safari, and is especially useful on large-screen devices like the iPad.  (Allen Pike&#8217;s <a href="http://www.antipode.ca/2010/choosing-a-viewport-for-ipad-sites/">Choosing a viewport for iPad sites</a> has a good explanation for web developers.)</p>
<p>For pages that set an initial or maximum scale, this means the <code>width</code> property actually translates into a <em>minimum</em> viewport width.  For example, if your layout needs at least 500 pixels of width then you can use the following markup.  When the screen is more than 500 pixels wide, the browser will expand the viewport (rather than zoom in) to fit the screen:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width=500, initial-scale=1&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>Fennec 1.1 also adds support for <code>minimum-scale</code>, <code>maximum-scale</code>, and <code>user-scalable</code>, with defaults and limits similar to <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html">Safari&#8217;s</a>.  These properties affect the initial scale and width, as well as limiting changes in zoom level.</p>
<p>Mobile browsers handle orientation changes slightly differently. For example, Mobile Safari often just zooms the page when changing from portrait to landscape, instead of laying out the page as it would if originally loaded in landscape.  If web developers want their scale settings to remain consistent when switching orientations on the iPhone, they must add a <code>maximum-scale</code> value to prevent this zooming, which has the sometimes-unwanted side effect of preventing users from zooming in:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;initial-scale=1, maximum-scale=1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>This is not necessary in Fennec; when the device changes orientation, Fennec updates the viewport size, the page layout, and JavaScript/CSS properties like <code>device-width</code>, based on its new “window” dimensions.</p>
<h2>Standards</h2>
<p>There is clearly demand for the viewport meta tag, since it is supported by most popular mobile browsers and used by thousands of web sites.  It would be good to have a true standard for web pages to control viewport properties. According to the HTML5 spec, extensions to the <code>meta</code> element should first be registered on the <a href="http://wiki.whatwg.org/wiki/MetaExtensions">WHATWG wiki</a> and then go through the W3C standards process.  If this happens, then we at Mozilla will work to make sure we can implement any changes made during standardization.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/upcoming-changes-to-the-viewport-meta-tag-for-firefox-mobile/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Firefox, YouTube and WebM</title>
		<link>http://hacks.mozilla.org/2010/05/firefox-youtube-and-webm/</link>
		<comments>http://hacks.mozilla.org/2010/05/firefox-youtube-and-webm/#comments</comments>
		<pubDate>Wed, 19 May 2010 16:24:23 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4817</guid>
		<description><![CDATA[Five important items of note today relating to Mozilla&#8217;s support for the VP8 codec: 1. Google will be releasing VP8 under an open source and royalty-free basis. VP8 is a high-quality video codec that Google acquired when they purchased the company On2. The VP8 codec represents a vast improvement in quality-per-bit over Theora and is [...]]]></description>
			<content:encoded><![CDATA[<p>Five important items of note today relating to <a href="http://blog.mozilla.com/blog/2010/05/19/open-web-open-video-and-webm/">Mozilla&#8217;s support for the VP8 codec</a>:</p>
<p>1. <strong>Google will be releasing VP8 under an open source and royalty-free basis.</strong>  VP8 is a high-quality video codec that Google acquired when they purchased the company <a href="http://www.on2.com">On2</a>.  The VP8 codec represents a vast improvement in quality-per-bit over Theora and is comparable in quality to H.264.</p>
<p>2. <strong>The VP8 codec will be combined with the Vorbis audio codec and a subset of the Matroska container format to build a new standard for Open Video on the web called WebM.</strong>  You can find out more about the project at its new site: <a href="http://www.webmproject.org/">http://www.webmproject.org/</a>.</p>
<p>3. <strong>We will include support for WebM in Firefox.</strong>  You can get super-early <a href="http://nightly.mozilla.org/webm">WebM</a> builds of Firefox 4 pre-alpha today.  WebM will also be included in Google Chrome and Opera.</p>
<p>4. <strong>Every video on YouTube will be transcoded into WebM.</strong>  They have about 1.2 million videos available today and will be working through their back catalog over time.  But they have committed to supporting everything.</p>
<p>5. <strong>This is something that is supported by many partners, not just Google and others.</strong>  Content providers like Brightcove have signed up to support WebM as part of a full HTML5 video solution.  Hardware companies, encoding providers and other parts of the video stack are all part of the list of companies backing WebM.  Even Adobe will be supporting WebM in Flash.  Firefox, with its market share and principled leadership and YouTube, with its video reach are the most important partners in this solution, but we are only a small part of the larger ecosystem of video.</p>
<p>We&#8217;re extremely excited to see Google joining us to support Open Video.  They are making technology available on terms consistent with the Open Web and the W3C Royalty-Free licensing terms.  And &#8211; most importantly &#8211; they are committing to support a full open video stack on the world&#8217;s largest video site.  This changes the landscape for video and moves the baseline for what other sites have to do to maintain parity and keep up with upcoming advances in video technology, not to mention compatibility with the set of browsers that are growing their userbase and advancing technology on the web.</p>
<p>At Mozilla, we&#8217;ve wanted video on the web to move as fast as the rest of the web.  That has required a baseline of open technology to build on.  Theora was a good start, but VP8 is better.  Expect us to start pushing on video innovation with vigor.  We&#8217;ll innovate like the web has, moving from the edges in, with dozens of small revolutions that add up to something larger than the sum of those parts.  VP8 is one of those pieces, <a href="http://caniuse.com/#agents=All&#038;eras=All&#038;cats=HTML5&#038;statuses=rec,pr,cr,wd,ietf">HTML5 </a>is another.  If you watch this weblog, you can start to see those <a href="http://hacks.mozilla.org/2010/04/beyond-html5-experiments-with-interactive-audio/">other pieces starting to emerge as well</a>.  The web is creeping into more and more technologies, with Firefox leading the way.  We intend to keep leading the web beyond HTML5 to the next place it needs to be.</p>
<p>Today is a day of great change.  Tomorrow will be another.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/firefox-youtube-and-webm/feed/</wfw:commentRss>
		<slash:comments>96</slash:comments>
		</item>
		<item>
		<title>Getting involved with Account Manager</title>
		<link>http://hacks.mozilla.org/2010/05/getting-involved-with-account-manager/</link>
		<comments>http://hacks.mozilla.org/2010/05/getting-involved-with-account-manager/#comments</comments>
		<pubDate>Thu, 13 May 2010 23:01:23 +0000</pubDate>
		<dc:creator>Dan Mills</dc:creator>
				<category><![CDATA[Firefox 4]]></category>
		<category><![CDATA[Identity]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4792</guid>
		<description><![CDATA[It&#8217;s been a couple of weeks since we originally posted about Account Manager and we&#8217;ve gotten a lot of feedback. We&#8217;ve got a few opportunities for people to get more involved with the project, listed below. Join us at the Account Manager Meet-up or at IIW We are hosting an Account Manager Meet-up on Friday, [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a couple of weeks since we <a href="http://hacks.mozilla.org/2010/04/account-manager-coming-to-firefox/">originally posted about Account Manager</a> and we&#8217;ve gotten a lot of feedback.  We&#8217;ve got a few opportunities for people to get more involved with the project, listed below.</p>
<p><strong>Join us at the Account Manager Meet-up or at IIW</strong></p>
<p>We are hosting an <a href="https://wiki.mozilla.org/Firefox/Projects/AccountManager/Meetup">Account Manager Meet-up on Friday, May 21st at Mozilla&#8217;s Mountain View Headquarters</a>. This meetup will be an excellent opportunity to give your feedback on the <a href="https://wiki.mozilla.org/Labs/Weave/Identity/Account_Manager/Spec/Latest">draft specification</a> as we prepare to finalize it. So, if you are a web developer, sysadmin, protocol or security expert, RSVP <a href="http://www.mozilla.com/en-US/firefox/accountmanager/form">here</a>.</p>
<p>The summit will be from 1PM to 4PM followed by a &#8220;cantina&#8221; during which you&#8217;ll get a chance to meet with other Mozilla developers over informal drinks and snacks.</p>
<p>We&#8217;ll also be presenting at the <a href="http://iiw.idcommons.net/Main_Page">Internet Identity Workshop</a> next week; if you are planning on attending IIW look for the Account Manager talk and come and say hello!</p>
<p><strong>Browser-assisted registration</strong></p>
<p>Another way to help out is to add reigistration support to your site.  The latest version of the Account Manager add-on adds support for a basic registration flow, and we&#8217;re very interested in finding out what the Web development community thinks about it. Here&#8217;s what you need to do:</p>
<p>Add a snippet to the username-password-form profile in your AMCD:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">&quot;register&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;method&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;path&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/register-endpoint&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;id-type&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;email&quot;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then you need to add a method at /register-endpoint which will receive the user id and secret as POST parameters.  Your method should return 200 if the id and secret are OK, otherwise return 400 with a snippet of JSON (see the spec for details and examples).</p>
<p>You might need to change your content to accomodate this new model: after you return 200 the expectation is that there is a username+password pair which is valid, even though it might map to a disabled account.  For example, if you need to ask for additional information, have the user solve a captcha, or require email verification, simply keep the account disabled until those additional requirements have been met.</p>
<p><strong>Addressing cross-site request forgeries</strong></p>
<p>Based on feedback from the community, we&#8217;ve been investigating several possibilities for preventing CSRF attacks with Account Manager.  In addition to supporting CSRF tokens, the latest proposal leverages headers to achieve the same goal with fewer requests and without a session cookie.  Interested?  Join the discussion on our <a href="https://groups.google.com/group/mozilla-labs-online-identity?pli=1">forum</a>.</p>
<p><strong>Join us online</strong></p>
<p>Join our online community, visit the Account Manager <a href="http://www.mozilla.com/en-US/firefox/accountmanager/">feature page</a> to learn more about Account Manager, and to subscribe to our mailing list/forum.</p>
<p>If you add support for Account Manager to your site, please add yourself to the the <a href="https://wiki.mozilla.org/Firefox/Projects/AccountManager/SupportedSites">wiki page for early Account Manager sites</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/getting-involved-with-account-manager/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Firefox 4: the HTML5 parser &#8211; inline SVG, speed and more</title>
		<link>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/</link>
		<comments>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/#comments</comments>
		<pubDate>Tue, 11 May 2010 15:55:26 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4685</guid>
		<description><![CDATA[This is a guest post from Henri Sivonen, who has been working on Firefox&#8217;s new HTML5 parser. The HTML parser is one of the most complicated and sensitive pieces of a browser. It controls how your HTML source is turned into web pages and as such changes to it are rare and need to be [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a guest post from <a href="http://hsivonen.iki.fi/">Henri Sivonen</a>, who has been working on Firefox&#8217;s new HTML5 parser.  The HTML parser is one of the most complicated and sensitive pieces of a browser.  It controls how your HTML source is turned into web pages and as such changes to it are rare and need to be well-tested.  While most of Gecko has been rebuilt since its initial inception in the late 90s, the parser was one of the stand-outs as being &#8220;original.&#8221;  This replaces that code with a new parser that&#8217;s faster, compliant with the new HTML5 standard and enables a lot of new functionality as well.</em></p>
<p>A project to replace Gecko’s old HTML parser, dating from 1998, has been ongoing for some time now. The parser was just turned on by default on the trunk, so you can now try it out by simply <A HREF="http://nightly.mozilla.org/">downloading a nightly build</A> without having to flip any configuration switch.</p>
<p>There are four main things that improve with the new HTML5 parser:</p>
<ul>
<li>You can now use SVG and MathML inline in HTML5 pages, without XML namespaces.
<li>Parsing is now done off Firefox&#8217;s main UI thread, improving overall browser responsiveness.
<li>It&#8217;s improved the speed of <CODE>innerHTML</CODE> calls by about 20%.
<li>With the landing of the new parser we&#8217;ve fixed <a href="https://bugzilla.mozilla.org/buglist.cgi?status_whiteboard_type=substring&#038;status_whiteboard=[fixed%20by%20the%20HTML5%20parser]&#038;resolution=FIXED">dozens of long-standing parser related bugs</a>.
</ul>
<p>
<strong><a href="http://hsivonen.iki.fi/test/moz/html5-hacks-demo.html">Try the demo with a</a> <a href="http://nightly.mozilla.org">Firefox Nightly</a> or another HTML5-ready browser.  It should look like this:</a></strong>
</p>
<p>
<a href="http://hsivonen.iki.fi/test/moz/html5-hacks-demo.html"><img src="http://hacks.mozilla.org/wp-content/uploads/2010/05/html5-parser.png"/></a>
</p>
<p><strong>What Is It?</strong></p>
<p>The HTML5 parser in Gecko turns a stream of bytes into a DOM tree according to the <A HREF="http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html">HTML5 parsing algorithm</A>. </p>
<p>HTML5 is the first specification that tells implementors, in detail, how parse HTML. Before HTML5, HTML specifications didn’t say how to turn a stream of bytes into a DOM tree. In theory, HTML before HTML5 was supposed to be defined in terms of SGML. This implied a certain relationship between the source of valid HTML documents and the DOM. However, parsing wasn’t well-defined for invalid documents (and Web content most often isn’t valid HTML4) and there are SGML constructs that were in theory part of HTML but that in reality popular browsers didn’t implement.</p>
<p>The lack of a proper specification led to browser developers filling in the blanks on their own and reverse engineering the browser with the largest market share (first Mosaic, then Netscape, then IE) when in doubt about how to get compatible behavior. This led to a lot of unwritten common rules but also to different behavior across browsers.</p>
<p>The HTML5 parsing algorithm standardizes well-defined behavior that browsers and other applications that consume HTML can converge on. By design, the HTML5 parsing algorithm is suitable for processing existing HTML content, so applications don’t need to continue maintaining their legacy parsers for legacy content. Concretely, in the trunk nightlies, the HTML5 parser is used for all <CODE>text/html</CODE> content.</p>
<p><strong>How Is It Different?</strong></p>
<p>The HTML5 parsing algorithm has two major parts: tokenization and tree building. Tokenization is the process of splitting the source stream into tags, text, comments and attributes inside tags. The tree building phase takes the tags and the interleaving text and comments and builds the DOM tree. The tokenization part of the HTML5 parsing algorithm is closer to what Internet Explorer does than what Gecko used to do. Internet Explorer has had the majority market share for a while, so sites have generally been tested not to break when subjected to IE’s tokenizer. The tree building part is close to what WebKit does already. Of the major browser engines WebKit had the most reasonable tree building solution prior to HTML5.</p>
<p>Furthermore, the new HTML5 parser parses network streams off the main thread. Traditionally, browsers have performed most tasks on the main thread. Radical changes like off-the-main-thread parsing are made possible by the more maintainable code base of the HTML5 parser compared to Gecko’s old HTML parser.</p>
<p><strong>What’s In It for Web Developers?</strong></p>
<p>The changes mentioned above are mainly of interest to browser developers. A key feature of the HTML5 parser is that you don’t notice that anything has changed.</p>
<p>However, there is one big new Web developer-facing feature, too: inline MathML and SVG. HTML5 parsing liberates MathML and SVG from XML and makes them available in the main file format of the Web.</p>
<p>This means that you can include typographically sophisticated math in your HTML document without having to recast the entire document as XHTML or, more importantly, without having to retrofit the software that powers your site to output well-formed XHTML. For example, you can now include the solution for quadratic equations inline in HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;math<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>x<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>=<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mfrac<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;minus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;PlusMinus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;msqrt<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;msup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>b<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/msup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;minus;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>c<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/msqrt<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #ddbb00;">&amp;InvisibleTimes;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>a<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mi<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mrow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mfrac<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/math<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Likewise, you can include scalable inline art as SVG without having to recast your HTML as XHTML. As screen sized and pixel densities become more varied, making graphics look crisp at all zoom levels becomes more important. Although it has previously been possible to use SVG graphics in HTML documents by reference (using the <CODE>object</CODE> element), putting SVG inline is more convenient in some cases. For example, an icon such as a warning sign can now be included inline instead of including it from an external file.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;svg</span> <span style="color: #000066;">height</span>=86 <span style="color: #000066;">width</span>=90 <span style="color: #000066;">viewBox</span>=<span style="color: #ff0000;">'5 9 90 86'</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">'float: right;'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">stroke</span>=#F53F0C <span style="color: #000066;">stroke-width</span>=10 <span style="color: #000066;">fill</span>=#F5C60C <span style="color: #000066;">stroke-linejoin</span>=round <span style="color: #000066;">d</span>=<span style="color: #ff0000;">'M 10,90 L 90,90 L 50,14 Z'</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;line</span> <span style="color: #000066;">stroke</span>=black <span style="color: #000066;">stroke-width</span>=10 <span style="color: #000066;">stroke-linecap</span>=round <span style="color: #000066;">x1</span>=50 <span style="color: #000066;">x2</span>=50 <span style="color: #000066;">y1</span>=45 <span style="color: #000066;">y2</span>=75 <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/svg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Make yourself a page that starts with <code>&lt;!DOCTYPE html&gt;</code> and put these two pieces of code in it and it should work with a new nightly.</p>
<p>In general, if you have a piece of MathML or SVG as XML, you can just copy and paste the XML markup inline into HTML (omitting the XML declaration and the doctype if any). There are two caveats: The markup must not use namespace prefixes for elements (i.e. no <CODE>svg:svg</CODE> or <CODE>math:math</CODE>) and the namespace prefix for the XLink namespace has to be <CODE>xlink</CODE>.</p>
<p>In the MathML and SVG snippits above you’ll see that the inline MathML and SVG pieces above are more HTML-like and less crufty than merely XML pasted inline. There are no namespace declarations and unnecessary quotes around attribute values have been omitted. The quote omission works, because the tags are tokenized by the HTML5 tokenizer—not by an XML tokenizer. The namespace declaration omission works, because the HTML5 tree builder doesn’t use attributes looking like namespace declarations to assign MathMLness or SVGness to elements. Instead, <CODE>&lt;svg&gt;</CODE> establishes a scope of elements that get assigned to the SVG namespace in the DOM and <CODE>&lt;math&gt;</CODE> establishes a scope of elements that get assigned to the MathML namespace in the DOM. You’ll also notice that the MathML example uses named character references that previously haven’t been supported in HTML.</p>
<p>Here’s a quick summary of inline MathML and SVG parsing for Web authors:</p>
<ul>
<li><CODE>&lt;svg&gt;</CODE>…<CODE>&lt;/svg&gt;</CODE> is assigned to the SVG namespace in the DOM.
<li><CODE>&lt;math&gt;</CODE>…<CODE>&lt;/math&gt;</CODE> is assigned to the MathML namespace in the DOM.
<li><CODE>foreignObject</CODE> and <CODE>annotation-xml</CODE> (an various less important elements) establish a nested HTML scope, so you can nest SVG, MathML and HTML as you’d expect to be able to nest them.
<li>The parser case-corrects markup so <CODE>&lt;SVG VIEWBOX=&#8217;0 0 10 10&#8242;&gt;</CODE> works in HTML source.
<li>The DOM methods and CSS selectors behave case-sensitively, so you need to write your DOM calls and CSS selectors using the canonical case, which is camelCase for various parts of SVG such as <CODE>viewBox</CODE>.
<li>The syntax <CODE>&lt;foo/&gt;</CODE> opens and immediately closes the <CODE>foo</CODE> element if it is a MathML or SVG element (i.e. not an HTML element).
<li>Attributes are tokenized the same way they are tokenized in HTML, so you can omit quotes in the same situations where you can omit quotes in HTML (i.e. when the attribute value is not the empty string and does not contain whitespace, <CODE>&quot;</CODE>, <CODE>&#8216;</CODE>, <CODE>`</CODE>, <CODE>&lt;</CODE>, <CODE>=</CODE>, or <CODE>&gt;</CODE>).
<li><B>Warning:</B> the two above features do not combine well due to the reuse of legacy-compatible HTML tokenization. If you omit quotes on the last attribute value, you must have a space before the closing slash. <CODE>&lt;circle fill=green /&gt;</CODE> is OK but <CODE>&lt;circle fill=red/&gt;</CODE> is not.
<li>Attributes starting with <CODE>xmlns</CODE> have <I>absolutely no effect</I> on what namespace elements or attributes end up in, so you don’t need to use attributes starting with <CODE>xmlns</CODE>.
<li>Attributes in the XLink namespace must use the prefix <CODE>xlink</CODE> (e.g. <CODE>xlink:href</CODE>).
<li>Element names must not have prefixes or colons in them.
<li>The content of SVG <CODE>script</CODE> elements is tokenized like they are tokenized in XML—not like the content of HTML <CODE>script</CODE> elements is tokenized.
<li>When an SVG or MathML element is open <CODE>&lt;![CDATA[</CODE>…<CODE>]]&gt;</CODE> sections work the way they do in XML. You can use this to hide text content from older browsers that don’t support SVG or MathML in <CODE>text/html</CODE>.
<li>The MathML named characters are available for use in named character references everywhere in the document (also in HTML content).
<li>To deal with legacy pages where authors have pasted partial SVG fragments into HTML (who knows why) or used a <CODE>&lt;math&gt;</CODE> tag for non-MathML purposes, attempts to nest various common HTML elements as children of SVG elements (without <CODE>foreignObject</CODE>) will immediately break out of SVG or MathML context. This may make some typos have surprising effects.
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-inline-svg-speed-and-more/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>Revitalizing Caching</title>
		<link>http://hacks.mozilla.org/2010/05/revitalizing-caching/</link>
		<comments>http://hacks.mozilla.org/2010/05/revitalizing-caching/#comments</comments>
		<pubDate>Mon, 03 May 2010 19:42:51 +0000</pubDate>
		<dc:creator>Arun Ranganathan</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Offline]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4645</guid>
		<description><![CDATA[Apparently, there are only two hard problems in computer science: cache invalidation and the naming of things (or so Phil Karlton&#8217;s dictum goes). Earlier this month, we invited representatives of Twitter, Facebook, SproutCore, Palm&#8217;s webOS, Microsoft&#8217;s &#8220;Office On The Web&#8221;, Yahoo, and Google to talk to us about the former problem (amongst other things), though [...]]]></description>
			<content:encoded><![CDATA[<p>Apparently, there are only two hard problems in computer science: cache invalidation and the naming of things (or <a href="http://martinfowler.com/bliki/TwoHardThings.html">so Phil Karlton&#8217;s dictum goes</a>).  Earlier this month, we invited representatives of <a href="http://www.twitter.com/">Twitter</a>, <a href="http://www.facebook.com/">Facebook</a>, <a href="http://www.sproutcore.com/">SproutCore</a>, <a href="http://developer.palm.com/">Palm&#8217;s webOS</a>, <a href="http://www.officelive.com/">Microsoft&#8217;s &#8220;Office On The Web&#8221;</a>, <a href="http://www.yahoo.com/">Yahoo</a>, and <a href="http://www.google.com/">Google</a> to talk to us about the former problem (amongst other things), though we also learned something about the latter.</p>
<p>Caching is an important issue to get right on the web, not least of all because of the proliferation of web applications on mobile devices.  The goals of our caching summit were to identify <em>use cases</em> that would help us move forward with caching and with HTTP request efficiency. How desirable was rolling up our sleeves to look at <a href="http://www.mozilla.org/projects/netlib/http/pipelining-faq.html">HTTP/1.1 Pipelining</a> in Firefox, for instance?  What <em>else</em> was needed at the HTTP layer?  And was the vaunted <a href="https://developer.mozilla.org/En/Offline_resources_in_Firefox">HTML5 AppCache</a>, implemented in Firefox 3.5 onwards, <em>actually useful</em> to developers?  What else needed to be exposed to web applications, either within content or via additional headers? </p>
<p>Developer feedback is invaluable, and is increasingly the basis of how we want to evolve the next integral pieces of the web platform.  Web developers are one of our primary constituencies; going forward, we want them to help us prioritize what we should implement, and what we need to focus on with respect to web standards.  We chose our attendees wisely; if any group of people could talk about <em>web applications at scale</em>, the <em>current</em> performance of the cache, and their wishlist for <em>future browser caching behavior</em> on the web platform, it was this group of people.  And the feedback they gave us was copious and useful &#8212; our work is cut-out for us.  Notably, we&#8217;ve got a few actions we&#8217;re going to follow-up on: </p>
<ul>
<li>
<p>Increase the default size of our disk and memory caches.  Firefox&#8217;s disk cache is currently set at 50MB, a small-ish number given the amount of disk space available on hardware currently (and although this limit <em>can</em> be increased using advanced preferences, few users actually change the default).   This is low-hanging fruit for us to fix.  An interesting open question is whether we should determine disk cache size <em>heuristically</em>, in lieu of choosing a new upper bound.  <a href="http://www.stevesouders.com">Steve Souders</a>, who attended our caching summit, blogs about <a href="http://www.stevesouders.com/blog/2010/04/26/call-to-improve-browser-caching/">cache sizes, as well as premature cache evictions</a>.  </p>
</li>
<li>
<p>Conduct a <a href="https://testpilot.mozillalabs.com/">&#8220;Mozilla Test-Pilot&#8221; project</a> to get more data about how <em>exactly</em> we cache resources currently.  This is part of a larger question about updating our caching algorithm.  Like other browsers, we use an optimization of the <em>Least Recently Used</em> (LRU) caching algorithm, called <a href="http://www.computer.org/portal/web/csdl/doi/10.1109/CMPSAC.2000.884690">LRU-SP</a>.  Data that we would want to gather includes determining what the hit rate, mean, variance and distribution of cached resources are.  What&#8217;s the average lifetime? How about different modes where our LRU-SP replacement policy doesn&#8217;t work well for certain apps, where big resources (such as an essential script file) may get eliminated before smaller ones (such as map tiles)?  We&#8217;ll also have to research the role that anti-virus software plays in routinely flushing out the cache, leading to further occurrences of untimely eviction of relevant resources.
</li>
<li>
<p>Explore prioritization of resources in the cache based on MIME type.  For instance, allowing for JavaScript (text/javascript) to always get higher priority in terms of what gets pruned by our LRU-SP algorithm.  A good follow-up for this would be to get Chrome, IE, Apple, and Opera to discuss this with us, and then document what we come up with as a MIME-type based &#8220;naive&#8221; prioritization.  We also want to allow developers to set resource priority on their own, perhaps through a header.  This is likely to be an ongoing discussion. </p>
</li>
<li>
<p><em>Really</em> figure out what hampers the adoption of  <a href="http://www.mozilla.org/projects/netlib/http/pipelining-faq.html">HTTP/1.1 Pipelining</a> on the web, including data from proxies and how they purge.  While Pipelining is enabled in <a href="http://www.mozilla.com/en-US/mobile/">Mobile Firefox</a> builds (such at that running on the Nokia N900 and on Android devices) by default, we have it turned off in desktop Firefox builds.  We do this for a variety of reasons, not least of all the risk of performance slow downs if one of the pipelined requests slows down the others.  It&#8217;s clear from our discussion that many who attended our caching summit think pipelining will help their applications perform much better.  The situation on the web now with respect to pipelining is a kind of hostage&#8217;s dilemma: of the main desktop browsers, nobody has turned on pipelining, for fear of a scenario that slows down performance (leading to that particular browser being accused of &#8220;being slow&#8221;).  The developers who visited us threw down the proverbial gauntlet;  at a minimum we&#8217;ve got to figure out what hamstrings the use of pipelining on the web, and determine what we can actually do to remove those obstacles.
</li>
<li>
<p>Figure out how to evolve the <a href="https://developer.mozilla.org/En/Offline_resources_in_Firefox">HTML5 AppCache</a>, which frankly hasn&#8217;t seen the adoption we initially expected.  While we tend to view parts of HTML5 such as <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html">Cache Manifests and <code>window.applicationCache</code></a> as yet another performance tool (to ensure web applications rapidly load upon subsequent accesses), it is different than the <em>general browser cache</em>.  What&#8217;s in a name, and why is naming something amongst the hardest problems in computer science?  The use of the word <em>&#8220;cache&#8221;</em> to describe the parts of HTML5 that deal with offline web applications has confused some developers.  What we&#8217;re calling the <em>HTML5 AppCache</em> was primarily conceived of to enable <em>offline</em> web application use, but many applications (such as those built with <a href="http://www.sproutcore.com/">SproutCore</a>) treat it as an auxiliary cache, to ensure that applications have a rapid start-up time and generally perform well.  Why, we were asked, should we have <em>two</em> things: a general purpose browser cache, and something else, uniquely for offline usage?  On the one hand, the HTML5 AppCache allows web apps to act like native apps (enabling &#8220;rapid-launch icons&#8221; on some mobile handsets), perhaps even eventually integrating with native application launchers.  And on the other hand, the HTML5 AppCache&#8217;s <em>separateness</em> from the general cache may mean that we coin different APIs to work with the general cache.  In general, simultaneously evolving multiple APIs with <em>&#8220;cache&#8221;</em> in the name may be confusing.  But that&#8217;s why naming is amongst the hard problems, and that&#8217;s why we have to architect the next iteration mindful of the potential for both redundancy as well as confusion. </p>
</li>
<p>We&#8217;ve got a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=559729">tracking bug in place</a> with a bold moniker: &#8220;Improve HTTP Cache.&#8221;  You&#8217;ll see the gamut of changes we&#8217;d like to introduce here, including benchmarking our cache against Chromium&#8217;s (and perhaps just using Chromium&#8217;s cache code, if we need to). </p>
<p>Caching is important, but difficult.  It would be fair to describe most of the near-term evolution of the web that way, whether that is the introduction of an indexable database capability, streaming video, or new layout models within CSS.  These evolutions won&#8217;t necessarily happen within a standards body or on a listserv, but rather through rapid prototyping and meaningful feedback.  That&#8217;s why we have to talk to web developers to help us do the right thing, and that&#8217;s why we&#8217;ll keep organizing meet-ups such as the recent caching summit.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/05/revitalizing-caching/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>WebSockets in Firefox</title>
		<link>http://hacks.mozilla.org/2010/04/websockets-in-firefox/</link>
		<comments>http://hacks.mozilla.org/2010/04/websockets-in-firefox/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 17:11:19 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Feature]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[WebSocket]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4491</guid>
		<description><![CDATA[Here&#8217;s the pitch for WebSockets: a low-complexity, low-latency, bi-directional communication system that has a pretty simple API for web developers. Let&#8217;s break that down, and then talk about if and when we&#8217;re going to include it in Firefox: Low-complexity The WebSocket protocol, which is started via an HTTP-like handshake, has a relatively simple model for [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the pitch for <a href="http://en.wikipedia.org/wiki/Web_Sockets">WebSockets</a>: a low-complexity, low-latency, bi-directional communication system that has a <a href="http://dev.w3.org/html5/websockets/#websocket">pretty simple API</a> for web developers.  Let&#8217;s break that down, and then talk about if and when we&#8217;re going to include it in Firefox:</p>
<p><strong>Low-complexity</strong></p>
<p>The WebSocket protocol, which is started via an HTTP-like handshake, has a relatively simple model for sending text packets back and forth.  The complexity of the protocol is quite low.  There&#8217;s no multiplexing, no support for binary data, and once the data connection is set up, the actual transport is quite cheap.</p>
<p>Note that there are people who feel &#8211; possibly correctly &#8211; that support for multiplexing and binary data should be added.  That would obviously increase the complexity but in some cases might be worth the cost.  But more on that later.</p>
<p><strong>Bi-directional Communication</strong></p>
<p>One of the key aspects of WebSocket is its support for simple bi-directional communication.  Servers can easily send updates to clients and clients can send updates to servers.  Many of the <a href="http://en.wikipedia.org/wiki/Comet_%28programming%29">comet-style</a> applications that people have built will be much simpler and faster with this model because the protocol and API support it directly.</p>
<p>While allowing for bi-directional communication it also is bound by the HTTP same-origin model.  That is, it&#8217;s doesn&#8217;t give the browser the ability to connect to any site on any port it wants to.</p>
<p>So WebSocket is really TCP with the HTTP security model.</p>
<p><strong>Low-latency</strong></p>
<p>This is actually the primary value in WebSockets.  The key thing is that the cost of sending a small amount of data is also very small.  It&#8217;s possible to do bi-directional communication today with comet-style applications, but small amounts of data often require a huge amount of overhead to do so.</p>
<p>A second-hand story to give you a sense of scale: Google Wave, which tries to do real-time communication with keystrokes has a several-kilobyte overhead for just about every keystroke because of the TCP startup, teardown and HTTP message headers involved with what should be only a few bytes sent over the wire.</p>
<p>I haven&#8217;t tried, but I&#8217;m going to guess that if you built <a href="http://code.google.com/p/quake2-gwt-port/">Quake</a> on top of HTTP comet that the interactive experience would be poor.  So this is where WebSockets really shine.</p>
<p><strong>Simple API</strong></p>
<p>The <a href="http://dev.w3.org/html5/websockets/#the-websocket-interface">actual API</a> that a developer sees for WebSocket is relatively simple.  You can send messages, you can get messages, you get events when sockets open, close or there&#8217;s an error.  Additional complexity, which I&#8217;m sure others will develop, will happen in JavaScript and backend libraries.</p>
<p>(While this might seem like punting on the issue of complexity, this is actually the model for success we&#8217;ve seen for other browser standards: build something relatively simple that others can experiment with.  When we understand what&#8217;s slow or what&#8217;s preventing progress, iterate and improve.)</p>
<p><strong>When will it be in Firefox?</strong></p>
<p>We really really want to support WebSockets in the next version of Firefox.  And a lot of other people want us to include support too.</p>
<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=472529">The first set of test patches</a>, written by the wonderful Wellington Fernando de Macedo (one of our most excellent contributors!) was first submitted in April of 2009.  Since then we&#8217;ve been iterating both on the patches themselves and following the spec as it&#8217;s changed.</p>
<p>Unfortunately, the spec itself is still under revision.  WebSockets did ship in <a href="http://blog.chromium.org/2009/12/web-sockets-now-available-in-google.html">Chrome</a> with version 4 and I&#8217;m told by Chrome developers that it&#8217;s going to be included in Chrome 5, without changes.  Unfortunately, the <a href="http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75">version that Google included in Chrome</a> doesn&#8217;t reflect the <a href="http://www.whatwg.org/specs/web-socket-protocol/">current draft</a>.  The handshake for how to start a WebSocket connection has changed, largely to improve security on servers.  There&#8217;s also a lot of ongoing discussion on the role of <a href="http://www.ietf.org/mail-archive/web/hybi/current/msg01810.html">integrated compression</a>, direct support for binary data (instead of encoding binary data as strings), whether or not the protocol should support multiplexing and a number of other issues.</p>
<p>Since WebSocket isn&#8217;t used widely yet, and that Chrome has an uptake rate that&#8217;s similar to Firefox, the hope is that once a more recent draft makes it through the process that both Chrome and Firefox can include a more recent version at around the same time.</p>
<p>So in short: we want to ship it because the promise of WebSockets is great, but we&#8217;ll have to see if it&#8217;s stable and safe enough to do so.  Code isn&#8217;t the issue &#8211; we&#8217;ve had that for a while.  It&#8217;s whether or not there&#8217;s consensus on if the protocol is &#8220;done enough&#8221; to ship it to a few hundred million people.</p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/04/websockets-in-firefox/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>The CSS 3 Flexible Box Model</title>
		<link>http://hacks.mozilla.org/2010/04/the-css-3-flexible-box-model/</link>
		<comments>http://hacks.mozilla.org/2010/04/the-css-3-flexible-box-model/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:43:31 +0000</pubDate>
		<dc:creator>Paul Rouget</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4034</guid>
		<description><![CDATA[This article about the Flexible Box Layout was written by Jérémie Patonnier, French open Web enthusiast. The flexible box model CSS 3 introduces a brand new box model in addition of the traditional box model from CSS 1 and 2. The flexible box model determines the way boxes are distributed inside other boxes and the [...]]]></description>
			<content:encoded><![CDATA[<p><em>This article about the Flexible Box Layout was written by <a href="http://jeremie.patonnier.net/">Jérémie Patonnier</a>, French open Web enthusiast.</em></p>
<h2>The flexible box model</h2>
<p>CSS 3 introduces a brand new box model in addition of the traditional box model from CSS 1 and 2. The flexible box model determines the way boxes are distributed inside other boxes and the way they share the available space.</p>
<p>You can see the specification <a href="http://www.w3.org/TR/css3-flexbox/">here</a>.</p>
<p>This box model is similar to the one used by XUL (the user interface language used by Firefox). Some others languages use similar box models such as XAML or GladeXML.</p>
<p>Usually the flexible box model is exactly what you need if you want to create fluid layouts which adapt themselves to the size of the browser window or elastic layouts which adapt themselves to the font size.</p>
<p>In this article, all my examples are based on the following HTML code:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box1&quot;</span>&gt;</span>1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box2&quot;</span>&gt;</span>2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;box3&quot;</span>&gt;</span>3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></pre></div></div>

<h2>Distributing boxes: so what?</h2>
<p>By default, the traditional CSS box model distributes boxes vertically depending on the HTML flow. With the flexible box model, it&#8217;s possible to specify the order explicitly. You can even reverse it. To switch to the flexible box model, set the property <code>display</code> to the value <code>box</code> (or <code>inline-box</code>) on a box which has child boxes.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span></pre></div></div>

<h3>Horizontal or vertical distribution</h3>
<p>The <code>box-orient</code> property lets you specify the distribution axis. <code>vertical</code> and <code>horizontal</code> values define how boxes are displayed. Other values (<code>inline-axis</code> and <code>block-axis</code>) have the same effect, but also let you define the baseline alignment itself (basically the boxes are treated like &#8220;inline&#8221; boxes).</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span>
  box-orient<span style="color: #00AA00;">:</span> horizontal<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><a hreflang="en" href="http://hacks.mozilla.org/wp-content/uploads/2010/04/exemple-simple.html#exemple1"><img title="Boxes horizontally displayed" alt="" src="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple1.png" /></a></p>
<h3>Reversed distribution</h3>
<p>The property <code>box-direction</code> allows you to set the order in which the boxes appear. By default&#8211;when you simply specify the distribution axis&#8211;the boxes follow the HTML flow and are distributed from top to bottom if you are using a vertical axis and from left to right if you are using a horizontal axis. By setting <code>box-direction</code> to <code>reverse</code>, you can reverse the boxes&#8217; distribution order. It acts as if you actually reversed the order of the elements in the HTML.</p>
<p>Be careful with this property because it changes the way some other properties work, which can produce some unexpected behavior.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span>
  box-orient<span style="color: #00AA00;">:</span> vertical<span style="color: #00AA00;">;</span>
  box-<span style="color: #000000; font-weight: bold;">direction</span><span style="color: #00AA00;">:</span> reverse<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><a hreflang="en" href="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple-simple.html#exemple2"><img title="Boxes vertically displayed in reverse order" alt="" src="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple2.png" /></a></p>
<h3>Explicit distribution</h3>
<p>The property <code>box-ordinal-group</code> lets you specify the order in which the boxes will be distributed. This is the ultimate customization opportunity, because you can define the order you want, regardless of the HTML flow order. Those groups are defined by a number starting at 1 (which is the default value). So the box model will first distribute those groups, then all the boxes inside each group. The distribution occurs from the lowest value (the group numbered 1) to the highest (the groups numbered 2 and above).</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span>
  box-orient<span style="color: #00AA00;">:</span> vertical<span style="color: #00AA00;">;</span>
  box-<span style="color: #000000; font-weight: bold;">direction</span> <span style="color: #00AA00;">:</span> reverse<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box1</span> <span style="color: #00AA00;">&#123;</span>
  box-ordinal-group<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box2</span> <span style="color: #00AA00;">&#123;</span>
  box-ordinal-group<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box3</span> <span style="color: #00AA00;">&#123;</span>
  box-ordinal-group<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><a hreflang="en" href="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple-simple.html#exemple3"><img title="Boxes vertically displayed with a chosen order" alt="" src="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple3.png" /></a></p>
<h2>And what about flexibility?</h2>
<p>If changing the natural HTML flow order is huge, the real fun begins when you start to deal with the available space.</p>
<h3>Box sizing</h3>
<p>By default, a box is not flexible. It becomes flexible only if it has the property <code>box-flex</code> with a value of at least 1.</p>
<p>If a box is not flexible, it will be as wide as possible to make its content visible without any overflow. Its size can be forced with the properties <code>width</code> and <code>height</code> (or their <code>min-*</code>, and <code>max-*</code> alternatives).</p>
<p>If a box is flexible, its size will be computed as follows:</p>
<ol>
<li>The explicit size declarations (<code>width</code>, <code>height</code>, <code>min-*</code> and <code>max-*</code>)</li>
<li>The size of the parent box and all the remaining available inner space.</li>
</ol>
<p>So, if the boxes haven&#8217;t any size declarations, their sizes will fully depend on their parent box&#8217;s size. It will work like this: the size of box is equal to the size of its parent multiplied by the value of the its <code>box-flex</code> property divided by the sum of all the <code>box-flex</code> properties values of all boxes included in its parent.</p>
<p>On the other hand, if one or more boxes have an explicit size statements, the size of all those boxes is computed and all the flexible boxes share the remaining available space on the same principle as above.</p>
<p>It probably sounds a bit tricky, but with some examples it will become easier.</p>
<h4>All boxes are flexible</h4>
<p>In the next example, box 1 is twice the size of box 2 and box 2 has the same size as box 3. It looks the same as using percentages to set the boxes&#8217; sizes. But there is a big difference. If you add a box, you don&#8217;t need to recalculate its size. With the flexible box model, each time you add a box, all the others automatically shrink to make room for the new one.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span>
  box-orient<span style="color: #00AA00;">:</span> horizontal<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box1</span> <span style="color: #00AA00;">&#123;</span>
  box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box2</span> <span style="color: #00AA00;">&#123;</span>
  box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box3</span> <span style="color: #00AA00;">&#123;</span>
  box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><a hreflang="en" href="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple-simple.html#exemple4"><img title="Flexiblity in action" alt="" src="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple4.png" /></a></p>
<h4>Some boxes have a fixed size</h4>
<p>In the next example, box 3, which is not flexible, is 160px in width. In this case, there&#8217;s 240px of free space available for boxes 1 and 2. So, box 1 will be 160px in width (240px x 2/3) and box 2 will be 80px in width (240px x 1/3). If you wish, you can make box 3 flexible as well. In this case the way the size of this box is computed will be almost the same as with the property <code>min-width</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span>
  box-orient<span style="color: #00AA00;">:</span> horizontal<span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">400px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box1</span> <span style="color: #00AA00;">&#123;</span>
  box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box2</span> <span style="color: #00AA00;">&#123;</span>
  box-flex<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#box3</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><a hreflang="en" href="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple-simple.html#exemple5"><img title="Mix of flexible and inflexible boxes" alt="" src="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple5.png" /></a></p>
<h3>Managing overflow</h3>
<p>Because we can mix flexible boxes, inflexible boxes, and flexible boxes which have preset sizes, It&#8217;s possible for the sum of all the boxes&#8217; sizes to be larger or smaller than the parent box size. So you can have too much space or not enough.</p>
<h4>I have too much space available; what do I do?</h4>
<p>The available space gets distributed depending on the properties <code>box-align</code> and <code>box-pack</code></p>
<p>The property <code>box-pack</code> manages the way the space is distributed on the horizontal axis and can have one of four possible values: <code>start</code>, <code>end</code>, <code>justify</code>, or <code>center</code></p>
<ol>
<li><code>start</code>: All the boxes are on the left side of the parent box and all the remaining space is on the right side.</li>
<li><code>end</code>: All the boxes are on the right and the remaining space is on the left</li>
<li><code>justify</code>: The available space is divided evenly in-between each boxes</li>
<li><code>center</code>: The available space is divided evenly on each side of the parent box</li>
</ol>
<p>The property <code>box-align</code> manages the way the space is distributed on the vertical axis and can have one of five values: <code>start</code>, <code>end</code>, <code>center</code>, <code>baseline</code>, and <code>stretch</code></p>
<ol>
<li><code>start</code>: The top edge of each box is placed along the top of the parent box and all the remaining space is placed below.</li>
<li><code>end</code>: The bottom edge of each box is placed along the bottom of the parent box and all the remaining space is placed above.</li>
<li><code>center</code>: The available space is divided evenly and placed half above and half below.</li>
<li><code>baseline</code>: All children are placed with their baselines aligned and the remaining space is placed before or after as necessary (<em>This is a simplification about how this value really works, but you see the point</em>).</li>
<li><code>stretch</code>: The height of each boxes is adjusted to fit the parent box height</li>
</ol>
<p>A warning about how those properties work: they are strongly influenced by the use of the properties <code>box-orient</code> and <code>box-direction</code>. They can cause some unexpected behavior (for example, the behavior of values <code>start</code> and <code>end</code> could be fully reversed). I hope that once the specification is finalized, we&#8217;ll have more information about how those properties work together.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> box<span style="color: #00AA00;">;</span>
  box-orient<span style="color: #00AA00;">:</span> horizontal<span style="color: #00AA00;">;</span>
  <span style="color: #808080; font-style: italic;">/* The content of the body is horizontally centered */</span>
  box-pack<span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
  <span style="color: #808080; font-style: italic;">/* and vertically as well ... \o/ */</span>
  box-align<span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span> <span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><a hreflang="en" href="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple-simple.html#exemple6"><img title="Boxes horizontally and vertically centered" alt="" src="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple6.png" /></a></p>
<h4>What happens if I don&#8217;t have enough space?</h4>
<p>Just like with the traditional box model, the overflow property lets you to define the way it&#8217;s managed. No surprise here.</p>
<p>However, you must be careful here too. Indeed, the use of the properties <code>box-orient</code> and <code>box-direction</code> can mess it up. For example, you can see elements overflowed to the right instead of the left or to the top instead of the bottom. Take the time to experiment before trying to use it on a big project or you could go mad.</p>
<p>You can also avoid overflow by making the boxes run over multiple lines (or columns, depending on the orientation) by setting the property <code>box-lines</code> to <code>multiple</code>.</p>
<h3>Okay, cool, but does it work in real life?</h3>
<p>Yes it does! Both Gecko and WebKit have vendor-prefixed implementations of a box model (<strong>Note</strong>: The current state of the specification does not reflect Mozilla&#8217;s or WebKit&#8217;s implementation). This means that Firefox, Safari, Chrome, and any browsers that use one of those rendering engines are able to use the features described in this article. If you use one of those awesome browsers, <a hreflang="en" href="http://hacks.mozilla.org/wp-content/uploads/2010/04/exemple-blog.html">here is a little demo of the flexible box model in action</a>.</p>
<p>If you&#8217;re not using a browser implementing a box model, this screenshot shows you what it looks like:</p>
<p><img title="An example of the flexible box model with a blog layout" alt="" src="http://hacks.mozilla.org/wp-content/uploads/2010/02/exemple-blog.png" /></p>
<h2>To conclude</h2>
<p>You can start to use this box model to layout your HTML documents with modern web browsers. Be careful though, it&#8217;s the really first iteration of a W3C Working Draft. There will certainly be some changes. Anyway, the implementations available in Gecko and Webkit are extremely consistent and mature, so if there are changes, they should not be that troublesome.</p>
<p>This box model is a very easy and simple way to solve some usual problems in web design (form layout, page footers, vertical centering, disassociation of visual flow from HTML flow, etc.). I strongly suggest you become familiar with it because it could become a standard tool for web designers in the near future (if Microsoft decides to include it in IE, it could become so very fast).</p>
<p>What is already available is a good start to play with. But at this point, the way the traditional box model and the flexible box model interact is not very clear (for example, it&#8217;s impossible to use <code>position:relative</code> with the properties <code>left</code> or <code>top</code> on a box which uses the property <code>box-ordinal-group</code>). This will be improved, but don&#8217;t be surprised if your work habits are somewhat undermined. Another tricky point: the way all the properties relative to this new box model interact can be sometimes really confusing. This should remind you of the day you discovered the <code>float</code> property. ;)</p>
<h3>For further information</h3>
<ul>
<li>Shawn J. Goff: <a hreflang="en" href="http://shawnjgoff.com/blog/css3-flexible-box-layout-module">CSS3 Flexible Box Layout Module</a></li>
<li>CSS3.info: <a hreflang="en" href="http://www.css3.info/introducing-the-flexible-box-layout-module/">Introducing the flexible box layout module</a></li>
<li>W3C: <a hreflang="en" href="http://www.w3.org/TR/css3-flexbox/">Flexible Box Layout Module</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/04/the-css-3-flexible-box-model/feed/</wfw:commentRss>
		<slash:comments>96</slash:comments>
		</item>
		<item>
		<title>mozilla developer preview 4 ready for testing</title>
		<link>http://hacks.mozilla.org/2010/04/mozilla-developer-preview-4-ready-for-testing/</link>
		<comments>http://hacks.mozilla.org/2010/04/mozilla-developer-preview-4-ready-for-testing/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 18:41:01 +0000</pubDate>
		<dc:creator>Christopher Blizzard</dc:creator>
				<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=4364</guid>
		<description><![CDATA[Note: this is a re-post of the entry in the Mozilla Project Development Weblog. There&#8217;s some juicy stuff in here for Web Developers that need testing. In particular, this is the first build with the CSS history changes. As part of our ongoing platform development work, we&#8217;re happy to announce the fourth pre-release of the [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: this is a re-post of the entry in the <a href="https://developer.mozilla.org/devnews/index.php/2010/04/12/mozilla-developer-preview-number-4-now-available/">Mozilla Project Development Weblog</a>.  There&#8217;s some juicy stuff in here for Web Developers that need testing.  In particular, this is the first build with the CSS history changes.</em></p>
<p>As part of our ongoing platform development work, we&#8217;re happy to announce the fourth pre-release of the Gecko 1.9.3 platform.  Gecko 1.9.3 will form the core of Firefox and other Mozilla project releases.</p>
<p>It&#8217;s <a href="http://www.mozilla.org/projects/devpreview/releasenotes/#download">available for download on Mac, Windows or Linux</a>.</p>
<p>Mozilla expects to release a Developer Preview every 2-3 weeks. If you&#8217;ve been running a previous release, you will be automatically updated to the latest version when it is released. </p>
<p>This preview release contains a lot of interesting stuff that&#8217;s worth pointing out, and contains many things that were also in <a href="http://developer.mozilla.org/devnews/index.php/2010/03/03/mozilla-developer-preview-now-available-with-out-of-process-plugins/">previous releases</a>.  Here are the things of note in this release:</p>
<p><b>User Interface Changes</b></p>
<ul>
<li>Open tabs that match searches in the Awesomebar now show up as &#8220;Switch to Tab.&#8221;</li>
<li>This is the first preview release to contain resizable text areas by default.</li>
</ul>
<p><b>Web Developer Changes</b></p>
<ul>
<li>This is the first preview release to contain changes to CSS :visited that prevent a large class of history sniffing attacks.  You can find more information about the details of why this change is important over on the <a href="http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/">hacks post on the topic</a> and on the <a href="http://blog.mozilla.com/security/2010/03/31/plugging-the-css-history-leak/">Mozilla Security Weblog</a>.  Note that this change is likely to break some web sites and requires early testing &#8211; please test if you can.
</li>
<li>SVG Attributes which are mapped to CSS properties can now be animated with SMIL.  See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=534028">the bug</a> or a <a href="http://people.mozilla.org/~dholbert/tests/smil/compat_tests/xmlVsCssChart_v1.svg">demo</a>.
</li>
</ul>
<p><b>Plugins</b></p>
<ul>
<li>
Out of process plugins support for Windows and Linux continues to improve.  This release contains many bug fixes vs. our previous developer preview releases.  (In fact, it&#8217;s good enough that we&#8217;ve ported this code back to the 3.6 branch and have <a href="http://www.mozilla.com/en-US/firefox/lorentz/">pushed that to beta for a later 3.6.x release</a>.)</li>
<li>This is the first release that contains support for out of process plugins for the Mac.  If you are running OSX 10.6 <i>and</i> you&#8217;re running the latest <a href="http://labs.adobe.com/downloads/flashplayer10.html">Flash beta</a>, Flash should run out of process</li>
</ul>
<p><b>Performance</b></p>
<ul>
<li>One area where people complained about performance was restart performance when applying an update.  It turns out that a lot of what made that experience poor wasn&#8217;t startup time, it was browser shutdown time.  We&#8217;ve made a fix since the last preview release that made a <a href="http://autonome.wordpress.com/2010/03/19/firefox-performance-update-startup-and-otherwise-march-19-2010/">whopping 97% improvement in shutdown time</a>.  (That&#8217;s not a typo, it&#8217;s basically free now.)</li>
<li>Our work to reduce the <a href="https://wiki.mozilla.org/Firefox/Goals/2010Q1/IO_Reduction">amount of I/O on the main thread</a> continues unabated.  This preview release will feel much snappier than previous snapshots, and feel <i>much</i> faster than Firefox 3.6.</li>
<li>We continue to add hardware acceleration support.  If you&#8217;re on Windows and you&#8217;ve got decent OpenGL 2 drivers, <a href="http://www.basschouten.com/blog1.php/2010/04/07/firefox-video-goes-up-to-11">open video will use hardware to scale the video when you&#8217;re in full screen mode</a>.  For large HD videos this can make a huge difference in the smoothness of the experience and how much power + CPU are used.  We&#8217;ll be adding OSX and Linux support at some point in the future as well, but we&#8217;re starting with Windows.</li>
<li>We continue to make improvements and bug fixes to our support for Direct2D.  (Not enabled by default.  If you want to turn it on see <a href="http://www.basschouten.com/blog1.php/2010/03/02/presenting-direct2d-hardware-acceleratio">Bas&#8217; post</a>.)  If you&#8217;re running Alpha 4 on Windows Vista or Windows 7, and you&#8217;ve turned on D2D, try running <a href="http://www.tapper-ware.net/stable/web.dom.stresstest.transform/">this stress test example in Alpha 4 vs. Firefox 3.6.</a>  The difference is pretty amazing.  You can also see what this looks like compared to other browsers in this <a href="http://www.tapper-ware.net/files/stresstest.comparison.ogg">this video.</a>  (Thanks to <a href="http://www.tapper-ware.net/">Hans Schmucker</a> for the video and demo.)
</li>
</ul>
<p><b>Platform</b></p>
<ul>
<li>
JS-ctypes, our new easy-to-use system for extension authors who want to call into native code now has support for complex types: structures, pointers, and arrays.  For more information on this, and how easy it can make calling into native code from JavaScript, see <a href="http://blog.mozilla.com/dwitte/2010/03/12/extension-authors-browser-hackers-meet-js-ctypes/">Dan Witte&#8217;s post</a>.</li>
<li>Mozilla is now sporting an infallible allocator.  What is this odd-sounding thing, you ask?  It&#8217;s basically an allocator that when memory can&#8217;t be allocated it aborts instead of returning NULL.  This reduces the surface area for an entire class of security bugs related to checking NULL pointers, and also allows us to vastly simplify a huge amount of Gecko&#8217;s source code.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/04/mozilla-developer-preview-4-ready-for-testing/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

