<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HTML5 Doctor &#187; JavaScript APIs</title>
	<atom:link href="http://html5doctor.com/category/javascript-apis/feed/" rel="self" type="application/rss+xml" />
	<link>http://html5doctor.com</link>
	<description>helping you implement HTML5 today</description>
	<lastBuildDate>Tue, 27 Jul 2010 14:36:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Introducing Web SQL Databases</title>
		<link>http://html5doctor.com/introducing-web-sql-databases/</link>
		<comments>http://html5doctor.com/introducing-web-sql-databases/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 10:15:39 +0000</pubDate>
		<dc:creator>Remy Sharp</dc:creator>
				<category><![CDATA[JavaScript APIs]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=1408</guid>
		<description><![CDATA[The Web SQL database API isn't actually part of the HTML5 specification, but it is part of the suite of specifications that allows us developers to build fully fledged web applications, so it was about time we dug around and checked out the deal.]]></description>
			<content:encoded><![CDATA[<p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
            <a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F">
                <img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;source=html5doctor&amp;style=normal&amp;service=is.gd" height="61" width="50" />
            </a>
        </div>The Web SQL database API isn&#8217;t actually part of the HTML5 specification, but it is part of the suite of specifications that allows us developers to build fully fledged web applications, so it&#8217;s about time we dig in and check it out.</p>

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

<h2>What&#8217;s in the box?</h2>

<p>If you haven&#8217;t guessed from the overly verbose specification title, Web SQL Databases is a spec that brings SQL to the client side. If you have a back-end developer&#8217;s background, then you&#8217;ll probably be familiar with SQL and happy as a pig in muck. If not, you might want to learn some SQL before you start hacking around, Google&#8217;s your friend here.</p>

<p>The specification is based around SQLite (3.1.19), but having come from MySQL myself, it&#8217;s all pretty much the same (sorry for the sweeping statement!).</p>

<p>For an example of Web SQL Databases working, have a look at the <a href="http://rem.im/html5-tweet-time-range.html">Twitter HTML5 chatter demo</a> I put together. It uses SQL and the WHERE clause to narrow down the recent chat about HTML5 on Twitter (it will work in Safari, Chrome and Opera 10.50).</p>

<p>There are three core methods in the spec that I&#8217;m going to cover in this article:</p>

<ol>
<li><code>openDatabase</code></li>
<li><code>transaction</code></li>
<li><code>executeSql</code></li>
</ol>

<p>Support is a little patchy at the moment. Only Webkit (Safari, SafariMobile and Chrome) and Opera 10.50 (<abbr title="at time of writing">ATOW</abbr> alpha on Mac) support web databases. Fellow Doctor <a href="http://html5doctor.com/author/brucel/">Bruce Lawson</a> has told me that Firefox are holding off as they feel there&#8217;s a better implementation than SQLite (though I hope it&#8217;s similar, whatever they pick). Either way, I&#8217;d definitely recommend checking out the <a href="http://sqlite.org">SQLite</a> documentation for the functions that are available.</p>

<p>Because of this patchy support and the simple fact that Webkit had implemented the database spec some time ago, the spec on the W3C is now slightly ahead of the implementations in Safari, while Webkit is still catching up. On the other hand, since Opera has only just added support, it&#8217;s closer to the spec (I&#8217;ll mention the differences as we go along).</p>

<p>Nonetheless, it&#8217;s fun to play with, so let&#8217;s get playing!</p>

<h2>Creating and Opening Databases</h2>

<p>If you try to open a database that doesn&#8217;t exist, the API will create it on the fly for you. You also don&#8217;t have to worry about closing databases.</p>

<p>To create and open a database, use the following code:</p>

<pre><code>var db = openDatabase('mydb', '1.0', 'my first database', 2 * 1024 * 1024);</code></pre>

<p>I&#8217;ve passed four arguments to the <code>openDatabase</code> method. These are:</p>

<ol>
<li>Database name</li>
<li>Version number</li>
<li>Text description</li>
<li>Estimated size of database</li>
</ol>

<p>The missing feature of <code>openDatabase</code> (I&#8217;m not sure when it was added) is the fifth argument:</p>

<ol start="5"><li>Creation callback</li></ol>

<p>The creation callback will be called if the database is being created. Without this feature, however, the databases are still being created on the fly and correctly versioned.</p>

<p>The return value from <code>openDatabase</code> contains the transaction methods, so we&#8217;ll need to capture this to be able to perform SQL queries.</p>

<h3>Estimated database size</h3>

<p>From the tests I&#8217;ve run, only Safari prompts the user if you try to create a database over the size of the default database size, 5MB. The prompt is shown the image below, asking whether you want to grant the database permission to scale up to the next size of database &#8212; 5, 10, 50, 100 and 500MB. Opera, on the other hand, builds the database without complaining, which I expect might change later as it&#8217;s still in alpha.</p>

<p><img src="http://html5doctor.com/wp-content/uploads/2010/02/webkit-db-size-prompt-e1266517048880.png" alt="Webkit database size prompt" title="Webkit database size prompt" /></p>

<h3>Versions</h3>

<p>I could be wrong, but everything I&#8217;ve tested so far says that versioning in SQL databases is borked. The problem is this:</p>

<p>If you upgrade your database to version 2.0 (e.g., there are some important schema changes since version 1.0), how do you know which visitors are on version 1.0 and which are on version 2.0?</p>

<p>The version number is a <strong>required</strong> argument to <code>openDatabase</code>, so you must <em>know</em> the version number before you try to open it. Otherwise, an exception is thrown.</p>

<p>Also, <code>changeVersion</code>, the method to change the database version, is not fully supported in Webkit. It works in Chrome and Opera, but not in Safari or Webkit. Regardless, if I can&#8217;t determine which version of database the user is on, then I can&#8217;t upgrade the user.</p>

<p>A possible workaround is to maintain a state database, something like the &#8216;mysql&#8217; database in MySQL. This way, you would only have <strong>one</strong> version of this state database, and within this you would record the current version of any databases that control your application. It&#8217;s a hack, but it works.</p>

<h2>Transactions</h2>

<p>Now that we&#8217;ve opened our database, we can create transactions. Why bother with transactions instead of just running our SQL? Transactions give us the ability to <em>rollback</em>. This means that if a transaction &#8212; which could contain one or more SQL statements &#8212; fails (either the SQL or the code in the transaction), the updates to the database are never committed &#8212; i.e. it&#8217;s as if the transaction <em>never happened</em>.</p>

<p>There are also error and success callbacks on the transaction, so you can manage errors, but it&#8217;s important to understand that transactions have the ability to rollback changes.</p>

<p>The transaction is simply a function that contains <em>some code</em>:</p>

<pre><code>var db = openDatabase('mydb', '1.0', 'my first database', 2 * 1024 * 1024);
db.transaction(function (tx) {
  // here be the transaction
  // do SQL magic here using the tx object
});</code></pre>

<p>I recently uploaded a demo to <a href="http://html5demos.com">html5demos.com</a> that demonstrates a transaction rollback in  action: <a href="http://html5demos.com/database-rollback">Web SQL database rollback demo</a></p>

<p>In the nightly builds of the browsers, we also have <code>db.readTransaction</code>, which allows only read statements to run on the database. I assume there are performance benefits to using a read-only <code>readTransaction</code> instead of a read/write <code>transaction</code>, most probably to do with table locking.</p>

<p>Now that we&#8217;ve got our transaction object (named <code>tx</code> in my example) we&#8217;re ready to run some SQL!</p>

<h2>executeSql</h2>

<p>This is the funnel of love for all your SQL goodness. <code>executeSql</code> is used for both read and write statements, includes SQL injection projection, and provides a callback method to process the results of any queries you may have written.</p>

<p>Once we have a transaction object, we can call <code>executeSql</code>:</p>

<pre><code>var db = openDatabase('mydb', '1.0', 'my first database', 2 * 1024 * 1024);
db.transaction(function (tx) {
  tx.executeSql('CREATE TABLE foo (id unique, text)');
});</code></pre>

<p>This will now create a simple table called &#8220;foo&#8221; in our database called &#8220;mydb&#8221;. Note that if the database already exists the transaction will fail, so any successive SQL wouldn&#8217;t run. So we can either use another transaction, or we can only create the table if it doesn&#8217;t exist, which I&#8217;ll do now so I can insert a new row in the same transaction:</p>

<pre><code>var db = openDatabase('mydb', '1.0', 'my first database', 2 * 1024 * 1024);
db.transaction(function (tx) {
  tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)');
  tx.executeSql('INSERT INTO foo (id, text) VALUES (1, "synergies")');
});</code></pre>

<p>Now our table has a single row inside it. What if we want to capture the text from the user or some external source? We&#8217;d want to ensure it can&#8217;t compromise the security of our database (using something nasty like SQL injection). The second argument to <code>executeSql</code> maps field data to the query, like so:</p>

<pre><code>tx.executeSql('INSERT INTO foo (id, text) VALUES (?, ?)', [id, userValue]);</code></pre>

<p><code>id</code> and <code>userValue</code> are external variables, and <code>executeSql</code> maps each item in the array argument to the <abbr title="question mark">&#8220;?&#8221;</abbr>s.</p>

<p>Finally, if we want to select values from the table, we use a callback to capture the results:</p>

<pre><code>tx.executeSql('SELECT * FROM foo', [], function (tx, results) {
  var len = results.rows.length, i;
  for (i = 0; i &lt; len; i++) {
    alert(results.rows.item(i).text);
  }
});</code></pre>

<p>(Notice that in this query, there are no fields being mapped, but in order to use the third argument, I need to pass in an empty array for the second argument.)</p>

<p>The callback receives the transaction object (again) and the results object. The results object contains a <code>rows</code> object, which is array-like but <strong>isn&#8217;t</strong> an array. It has a length, but to get to the individual rows, you need to use <code>results.rows.item(i)</code>, where <code>i</code> is the index of the row. This will return an object representation of the row. For example, if your database has a <code>name</code> and an <code>age</code> field, the row will contain a <code>name</code> and an <code>age</code> property. The value of the <code>age</code> field could be accessed using <code>results.rows.item(i).age</code>.</p>

<p>That&#8217;s all you should need to get started with Web SQL Databases. I&#8217;m certain that mini JavaScript libraries are going to emerge to help support working with databases. If you want to find out more about SQL databases (shameless self promotion begins) I just finished the storage chapter for <a href="http://www.amazon.com/Introduction-Html-5-Bruce-Lawson/dp/0321687299">Introducing HTML5</a>, which I&#8217;m writing with fellow Doc Bruce, so check that bad boy out too!</p>

<h2>Demos</h2>

<ul>
<li><a href="http://html5demos.com/database">HTML5 demo showing simple database usage</a></li>
<li><a href="http://html5demos.com/database-rollback">HTML5 demonstration of a transaction rolling back</a></li>
<li><a href="http://rem.im/html5-tweet-time-range.html">Demo showing time range selection using SQLite</a></li>
</ul>

<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://html5doctor.com/native-drag-and-drop/" rel="bookmark" class="crp_title">Native Drag and Drop</a></li><li><a href="http://html5doctor.com/native-audio-in-the-browser/" rel="bookmark" class="crp_title">Native Audio in the browser</a></li><li><a href="http://html5doctor.com/html5-custom-data-attributes/" rel="bookmark" class="crp_title">HTML5 Custom Data Attributes (data-*)</a></li><li><a href="http://html5doctor.com/your-questions-5/" rel="bookmark" class="crp_title">Your Questions Answered #5</a></li><li><a href="http://html5doctor.com/your-questions-answered-10/" rel="bookmark" class="crp_title">Your Questions Answered #10</a></li></ul></div>

<p>Share and Save:</p>

<pre><code>&lt;a rel="nofollow"  href="http://twitter.com/home?status=Introducing%20Web%20SQL%20Databases%20-%20http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F" title="Twitter"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;title=Introducing%20Web%20SQL%20Databases&amp;amp;bodytext=The%20Web%20SQL%20database%20API%20isn%27t%20actually%20part%20of%20the%20HTML5%20specification%2C%20but%20it%20is%20part%20of%20the%20suite%20of%20specifications%20that%20allows%20us%20developers%20to%20build%20fully%20fledged%20web%20applications%2C%20so%20it%20was%20about%20time%20we%20dug%20around%20and%20checked%20out%20the%20deal." title="Digg"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;amp;m=submit&amp;amp;link=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F" title="Sphinn"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;title=Introducing%20Web%20SQL%20Databases" title="Reddit"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;title=Introducing%20Web%20SQL%20Databases&amp;amp;notes=The%20Web%20SQL%20database%20API%20isn%27t%20actually%20part%20of%20the%20HTML5%20specification%2C%20but%20it%20is%20part%20of%20the%20suite%20of%20specifications%20that%20allows%20us%20developers%20to%20build%20fully%20fledged%20web%20applications%2C%20so%20it%20was%20about%20time%20we%20dug%20around%20and%20checked%20out%20the%20deal." title="del.icio.us"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;title=Introducing%20Web%20SQL%20Databases" title="StumbleUpon"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F" title="Technorati"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.netvibes.com/share?title=Introducing%20Web%20SQL%20Databases&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F" title="Netvibes"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;t=Introducing%20Web%20SQL%20Databases" title="Facebook"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;title=Introducing%20Web%20SQL%20Databases&amp;amp;annotation=The%20Web%20SQL%20database%20API%20isn%27t%20actually%20part%20of%20the%20HTML5%20specification%2C%20but%20it%20is%20part%20of%20the%20suite%20of%20specifications%20that%20allows%20us%20developers%20to%20build%20fully%20fledged%20web%20applications%2C%20so%20it%20was%20about%20time%20we%20dug%20around%20and%20checked%20out%20the%20deal." title="Google Bookmarks"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.friendfeed.com/share?title=Introducing%20Web%20SQL%20Databases&amp;amp;link=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F" title="FriendFeed"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;t=Introducing%20Web%20SQL%20Databases" title="HackerNews"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;title=Introducing%20Web%20SQL%20Databases&amp;amp;source=HTML5+Doctor+helping+you+implement+HTML5+today&amp;amp;summary=The%20Web%20SQL%20database%20API%20isn%27t%20actually%20part%20of%20the%20HTML5%20specification%2C%20but%20it%20is%20part%20of%20the%20suite%20of%20specifications%20that%20allows%20us%20developers%20to%20build%20fully%20fledged%20web%20applications%2C%20so%20it%20was%20about%20time%20we%20dug%20around%20and%20checked%20out%20the%20deal." title="LinkedIn"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.newsvine.com/_tools/seed&amp;amp;save?u=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;h=Introducing%20Web%20SQL%20Databases" title="NewsVine"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;amp;u=http%3A%2F%2Fhtml5doctor.com%2Fintroducing-web-sql-databases%2F&amp;amp;t=Introducing%20Web%20SQL%20Databases&amp;amp;s=The%20Web%20SQL%20database%20API%20isn%27t%20actually%20part%20of%20the%20HTML5%20specification%2C%20but%20it%20is%20part%20of%20the%20suite%20of%20specifications%20that%20allows%20us%20developers%20to%20build%20fully%20fledged%20web%20applications%2C%20so%20it%20was%20about%20time%20we%20dug%20around%20and%20checked%20out%20the%20deal." title="Tumblr"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /&gt;&lt;/a&gt;
</code></pre>

<p>&lt;br/>&lt;br/></p>
<p><a href="http://html5doctor.com/introducing-web-sql-databases/" rel="bookmark">Introducing Web SQL Databases</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on February 24, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/introducing-web-sql-databases/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Why designers should care about HTML5</title>
		<link>http://html5doctor.com/why-designers-should-care-about-html5/</link>
		<comments>http://html5doctor.com/why-designers-should-care-about-html5/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 13:01:06 +0000</pubDate>
		<dc:creator>Cennydd Bowles</dc:creator>
				<category><![CDATA[Comment]]></category>
		<category><![CDATA[JavaScript APIs]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[drag and drop]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[semantics]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=973</guid>
		<description><![CDATA[After a while on the fringes of our collective consciousness, HTML5 is finally getting the attention it deserves. The development community (as typified by the SuperFriends) has come together to debate practical elements of the spec, argue over the inclusion of controversial elements, and assess the timeframe over which we can unleash HTML5 in the wild.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;source=html5doctor&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>After a while on the fringes of our collective consciousness, <abbr title="Hypertext Markup Language 5">HTML5</abbr> is finally getting the attention it deserves. The development community (as typified by the <a href="http://www.zeldman.com/superfriends/">SuperFriends</a>) has come together to debate practical elements of the spec, argue over the inclusion of controversial elements, and assess the timeframe over which we can unleash <abbr>HTML</abbr>5 in the wild.</p>
<p>However those of us more accustomed to the world of Post-Its, sketches, and .psds – the designers – haven’t been so vocal. Perhaps we&#8217;ve been distracted by the bright lights of <a href="http://www.css3.info/">CSS3</a> and those surface thrills we’ve longed for. (Rounded corners! Gradients! Transparency!) Or, alternatively, we&#8217;ve been in the thrall of <code>@font-face</code> and looking forward to the coming age of passable web typography.</p>
<p>Understandable. But it’s time designers got excited about <abbr>HTML</abbr>5 too.</p>
<p>Partly, it’s just good practice. Whatever your flavour of design &ndash; visual, web, interaction, user experience &ndash; knowing the native technology makes you better at your job. Just as composers should understand the capabilities of the orchestra&#8217;s instruments, designers need to understand the language of the web.</p>
<p>But there’s more to <abbr>HTML</abbr>5 than simply keeping our skills sharp. It could make a big difference to the way we design for the web.</p>
<h2>Semantic elements</h2>
<p>Information architects (and, by extension, user experience designers) should be excited by the new <abbr>HTML</abbr>5 elements – <code>&lt;nav&gt;</code>, <code>&lt;header&gt;</code>, <code>&lt;aside&gt;</code> and so on. While they won’t immediately revolutionise today’s web, they’re an investment for the future. Doing useful stuff with information is the central theme of <abbr title="information architecture">IA</abbr>, and therefore its practitioners should be at the forefront of the new experiences that machine-readable semantics will offer. <abbr>HTML</abbr>5 allows us to mark text up in a more meaningful way than a sea of <code>&lt;div&gt;</code>s, meaning we’ll soon see applications appearing at a sub-page level. We’ve started to scratch the surface – think about the <a href="https://addons.mozilla.org/en-US/firefox/addon/4106">Operator toolbar</a> or customisable UIs à la <a href="http://www.google.com/ig">iGoogle</a> – but we’ll need detailed design thinking to work out how to bring the benefits of semantic richness to the end user.</p>
<h2>APIs and other extensions</h2>
<p>While it’s clear that <a href="http://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html">some of the <abbr>HTML</abbr>5 APIs are far from perfect</a> right now, when they&#8217;re refined they will offer us intriguing new opportunities and challenges.</p>
<p>Designers of location-based services should of course find the <a href="http://dev.w3.org/geo/api/spec-source.html">geolocation API</a> invaluable. The <a href="http://blog.whatwg.org/the-road-to-html-5-contenteditable">contentEditable attribute</a> gives us further power to make the web truly read/write without resorting to JavaScript and custom interfaces. New input types (eg <code>type=&quot;search&quot;</code>) can provide extra visual cues about input function, although of course this depends on the solutions chosen by the browser manufacturers.</p>
<p>Until now, it’s been easy to consider our domain as bounded by the viewport and the web server. But <abbr>HTML</abbr>5 is another step toward seamlessness: the merging of desktop, offline and online. For instance, the <a href="/native-drag-and-drop/">drag and drop API</a> could see the line between online and desktop experience blur further. Local storage could allow for a web-like experience in areas of poor connectivity. This convergence is clearly a good thing, but we must also design how to expose those hidden seams at the user’s request. Users should stay in control of how their locations are published and what data is synchronised to their machine.</p>
<h2>&lt;video&gt;, &lt;audio&gt;, &lt;canvas&gt;</h2>
<p>There is of course something of a reported schism between the standards world and the Flash world. Some see the advent of these new media elements (particularly <code>&lt;canvas&gt;</code>) as heralding the death of Adobe’s poster child.</p>
<p>I don&#8217;t think this is either likely or desirable. Neither technology is perfect. Flash is, of course, proprietary and thus subject to the whims of a third party that stands between browser and user. <code>&lt;canvas&gt;</code> has <a href="http://esw.w3.org/topic/HTML/AddedElementCanvas">known accessibility problems</a>. But the two can live in harmony, if we play to their respective strengths. Some current Flash applications might be better suited to <code>&lt;canvas&gt;</code>, particularly those based around dynamic visualisation: graphs, animations, infographics. Some applications will benefit from the powerful capabilities of Flash: games, heavily interactive widgets.</p>
<p>This aside, there’s clearly a user experience benefit in not having to rely on an external plugin to play rich media elements, and it will be interesting to see the uptake of the <code>&lt;video&gt;</code> and <code>&lt;audio&gt;</code> elements. Although it will initially be down to browser makers to define the interface elements involved, we will need to figure out how to integrate them into everyday web experiences. The good news is that they can be styled in the same way as any other <abbr>HTML</abbr> element. If your visual aesthetic relies on slanted images with box shadows, it&#8217;s trivial to apply this to video too.</p>
<p>That said, we can&#8217;t ignore the elephant in the room: <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2009-June/020620.html">the thorny codec issue</a>. I&#8217;m sure we&#8217;d all agree that the sooner it&#8217;s resolved, the better.</p>
<h2>What can designers do?</h2>
<p>Only the most patient and detail-oriented designer will relish the idea of reading the spec in full and arguing the finer points on the <a href="http://www.whatwg.org/mailing-list">WHATWG list</a>. That’s just not the way designers roll.</p>
<p>But as a community it’s important that we start talking about <abbr>HTML</abbr>5. If you&#8217;re new to <abbr>HTML</abbr>, now&#8217;s a great time to learn. The <a href="/article-archive/">articles on this site</a> and <a href="http://www.alistapart.com/articles/previewofhtml5/">A preview of HTML5</a> give useful guidance on the differences between <abbr>HTML</abbr>5 and its predecessors. Above all, designers should get chatting with their developer friends: there can’t be many left who no longer have an opinion on this technology. How do they see their practices changing? What can we do today to prepare our sites for the advent of HTML5? How can we build on its strong points to make the web a better place?</p>
<p>We don&#8217;t yet know what we&#8217;ll accomplish with <abbr>HTML</abbr>5, but then it&#8217;s not often that the vocabulary of the web changes this deeply. However, one thing is clear: if we prepare now, we have a great chance to bring innovation to our users&#8217; online lives.</p>
<p class="disclaimer">This article was jointly published on <a href="http://www.cennydd.co.uk/">Ineffable</a>, Cennydd&#8217;s personal website.</p>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul>
<li><a href="http://html5doctor.com/reviewing-html5-for-web-designers/" rel="bookmark" class="crp_title">Reviewing HTML5 for Web Designers</a></li>
<li><a href="http://html5doctor.com/video-the-track-element-and-webm-codec/" rel="bookmark" class="crp_title">Video: the track element and webM codec</a></li>
<li><a href="http://html5doctor.com/native-audio-in-the-browser/" rel="bookmark" class="crp_title">Native Audio in the browser</a></li>
<li><a href="http://html5doctor.com/draw-attention-with-mark/" rel="bookmark" class="crp_title">Draw attention with mark</a></li>
<li><a href="http://html5doctor.com/web-directions-atmedia-2010/" rel="bookmark" class="crp_title">HTML5 Doctor at Web Directions @media</a></li>
</ul>
</div>
<p>Share and Save:</p>
<p>	<a rel="nofollow"  href="http://twitter.com/home?status=Why%20designers%20should%20care%20about%20HTML5%20-%20http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F" title="Twitter"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;title=Why%20designers%20should%20care%20about%20HTML5&amp;bodytext=After%20a%20while%20on%20the%20fringes%20of%20our%20collective%20consciousness%2C%20HTML5%20is%20finally%20getting%20the%20attention%20it%20deserves.%20The%20development%20community%20%28as%20typified%20by%20the%20SuperFriends%29%20has%20come%20together%20to%20debate%20practical%20elements%20of%20the%20spec%2C%20argue%20over%20the%20inclusion%20of%20controversial%20elements%2C%20and%20assess%20the%20timeframe%20over%20which%20we%20can%20unleash%20HTML5%20in%20the%20wild." title="Digg"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F" title="Sphinn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;title=Why%20designers%20should%20care%20about%20HTML5" title="Reddit"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;title=Why%20designers%20should%20care%20about%20HTML5&amp;notes=After%20a%20while%20on%20the%20fringes%20of%20our%20collective%20consciousness%2C%20HTML5%20is%20finally%20getting%20the%20attention%20it%20deserves.%20The%20development%20community%20%28as%20typified%20by%20the%20SuperFriends%29%20has%20come%20together%20to%20debate%20practical%20elements%20of%20the%20spec%2C%20argue%20over%20the%20inclusion%20of%20controversial%20elements%2C%20and%20assess%20the%20timeframe%20over%20which%20we%20can%20unleash%20HTML5%20in%20the%20wild." title="del.icio.us"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;title=Why%20designers%20should%20care%20about%20HTML5" title="StumbleUpon"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F" title="Technorati"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Why%20designers%20should%20care%20about%20HTML5&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F" title="Netvibes"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;t=Why%20designers%20should%20care%20about%20HTML5" title="Facebook"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;title=Why%20designers%20should%20care%20about%20HTML5&amp;annotation=After%20a%20while%20on%20the%20fringes%20of%20our%20collective%20consciousness%2C%20HTML5%20is%20finally%20getting%20the%20attention%20it%20deserves.%20The%20development%20community%20%28as%20typified%20by%20the%20SuperFriends%29%20has%20come%20together%20to%20debate%20practical%20elements%20of%20the%20spec%2C%20argue%20over%20the%20inclusion%20of%20controversial%20elements%2C%20and%20assess%20the%20timeframe%20over%20which%20we%20can%20unleash%20HTML5%20in%20the%20wild." title="Google Bookmarks"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Why%20designers%20should%20care%20about%20HTML5&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F" title="FriendFeed"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;t=Why%20designers%20should%20care%20about%20HTML5" title="HackerNews"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;title=Why%20designers%20should%20care%20about%20HTML5&amp;source=HTML5+Doctor+helping+you+implement+HTML5+today&amp;summary=After%20a%20while%20on%20the%20fringes%20of%20our%20collective%20consciousness%2C%20HTML5%20is%20finally%20getting%20the%20attention%20it%20deserves.%20The%20development%20community%20%28as%20typified%20by%20the%20SuperFriends%29%20has%20come%20together%20to%20debate%20practical%20elements%20of%20the%20spec%2C%20argue%20over%20the%20inclusion%20of%20controversial%20elements%2C%20and%20assess%20the%20timeframe%20over%20which%20we%20can%20unleash%20HTML5%20in%20the%20wild." title="LinkedIn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;h=Why%20designers%20should%20care%20about%20HTML5" title="NewsVine"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml5doctor.com%2Fwhy-designers-should-care-about-html5%2F&amp;t=Why%20designers%20should%20care%20about%20HTML5&amp;s=After%20a%20while%20on%20the%20fringes%20of%20our%20collective%20consciousness%2C%20HTML5%20is%20finally%20getting%20the%20attention%20it%20deserves.%20The%20development%20community%20%28as%20typified%20by%20the%20SuperFriends%29%20has%20come%20together%20to%20debate%20practical%20elements%20of%20the%20spec%2C%20argue%20over%20the%20inclusion%20of%20controversial%20elements%2C%20and%20assess%20the%20timeframe%20over%20which%20we%20can%20unleash%20HTML5%20in%20the%20wild." title="Tumblr"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
<p><a href="http://html5doctor.com/why-designers-should-care-about-html5/" rel="bookmark">Why designers should care about HTML5</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 14, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/why-designers-should-care-about-html5/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Accessibility &amp; Native Drag and Drop</title>
		<link>http://html5doctor.com/accessibility-native-drag-and-drop/</link>
		<comments>http://html5doctor.com/accessibility-native-drag-and-drop/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 13:30:32 +0000</pubDate>
		<dc:creator>Remy Sharp</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[JavaScript APIs]]></category>
		<category><![CDATA[aria]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=603</guid>
		<description><![CDATA[A few days before my native drag and drop article came out Gez Lemon wrote about accessibility in drag and drop, and touched on HTML 5. I then promised to look at implementing accessibility with native drag and drop, and here's my findings.]]></description>
			<content:encoded><![CDATA[<p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
            <a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F">
                <img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;source=html5doctor&amp;style=normal&amp;service=is.gd" height="61" width="50" />
            </a>
        </div>A few days before my <a href="http://html5doctor.com/native-drag-and-drop/">native drag and drop</a> article came out <a href="http://juicystudio.com/">Gez Lemon</a> wrote about <a href="http://dev.opera.com/articles/view/accessible-drag-and-drop/">accessibility in drag and drop</a>, and touched on HTML 5.</p>

<p>I then promised to look at implementing accessibility with <em>native</em> drag and drop, and here&#8217;s my findings.</p>

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

<h2>ARIA Support</h2>

<p>This was quite easy to add, though only by following Gez&#8217;s article.  Since I already had events for drag start, I just needed to add drag end to clean up and remove the ARIA effects.</p>

<p>I added the following to the <code>dragstart</code> event:</p>

<pre><code>addEvent(dragItems, 'dragstart', function (event) {
  // via ARIA say the element has been grabbed
  this.setAttribute('aria-grabbed', 'true');
  // code continues...</code></pre>

<p>The added a new <code>dropend</code> event:</p>

<pre><code>addEvent(dragItems, 'dragend', function (event) {
  // remove the ARIA grab attibute when we're not dragging
  this.setAttribute('aria-grabbed', 'false');
});</code></pre>

<p>The <code>effectAllowed</code> and <code>dropEffect</code> combo was difficult to work out at first, though probably because I was playing with <code>link</code> and <code>reference</code>, whereas I should have been playing with <code>move</code> or <code>copy</code>.  That said, a note about <code>move</code> and <code>copy</code>, move is a type of copy, with a clean up function to delete afterwards.  Once I had this combo correct, the drop effects worked.</p>

<p>The changes required were to:</p>

<ol>
<li>On drag: on all the drop targets add: <code>setAttribute('aria-dropeffect', 'copy')</code></li>
<li>On drag: set the allowedEffect on the drag event: <code>event.dataTransfer.effectAllowed = 'copy';</code></li>
<li>On drop: say what we&#8217;ll accept: <code>event.dataTransfer.dropEffect = 'move';</code></li>
<li>On dragend: remove the drop effect from the drop targets: <code>removeAttribute('aria-dropeffect')</code></li>
</ol>

<p>The big problem for me was that I couldn&#8217;t truely test this.</p>

<p><strong>Update:</strong> between the time I had finished my code and writing this article, <a href="http://www.nvda-project.org/" title="NVDA">NVDA</a> (the Windows open source screenreader) announced that they recieved support from Yahoo!, and that ARIA drag and drop support is in their development roadmap.</p>

<p>The full working version of native drag and drop with ARIA support is available here: <a href="http://jsbin.com/obiqi">native drag and drop with ARIA support</a> (<a href="http://jsbin.com/obiqi/edit#html">source code</a>)</p>

<h2>Keyboard Support</h2>

<p>Keyboard, sadly, is a whole different story.</p>

<p>I was able to replicate a lot of the keyboard features that Gez included in his demo. This included setting the <code>tabIndex = 0</code> to allow the elements to tab to (superb trick by the way), included highlighting the drop targets as we drag.</p>

<p>However, the problem was: I wanted the user to be able to start the drag operation using the keyboard.  Initially looking at the spec I couldn&#8217;t see that it was supposed to be supported (which it turns out, it is).</p>

<p>I started going down the path of using the keyboard to trigger drag events.  I was able to replicate the drag event being triggered from the keyboard (like space starts the event), however, and this is a biggie, I couldn&#8217;t replicate the <code>dataTransfer</code> object.  I tried faking it.  I tried giving it nothing.  I tried all kinds of random attempts to trick the browser in to giving me the object.  It&#8217;s a no goer.</p>

<p>As it turns out, there <em>is</em> <a href="http://www.whatwg.org/specs/web-apps/current-work/#copy-and-paste">keyboard support</a> written in to the spec (though in my personally opinion it&#8217;s not completely obvious to an author reading).  The drag and drop operations should work like a copy and paste operation.</p>

<p>This is very clever, and I like it.  Tab round to the dragable element, copy using the keyboard, which triggers the <code>dragstart</code> event, which I can then add classes to the drop targets, and make them tabbable.  The user then tabs round to the drop targets, and pastes.  This triggers the <code>drop</code> event and we&#8217;re all good.</p>

<p>No browsers support this keyboard event model.</p>

<p>I&#8217;ve raised bug for <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=504533">Mozilla</a> and <a href="https://bugs.webkit.org/show_bug.cgi?id=27339">Webkit</a>.  They&#8217;ve both had comments on, and in both cases I&#8217;m not 100% sure what the comments mean, but speaking to the people involved via IRC, they&#8217;ve both said if it&#8217;s in the spec, it should be in the browser.</p>

<p>Let&#8217;s hope they do something about it. Now, how do I report a bug in IE&#8230;?!<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://html5doctor.com/native-drag-and-drop/" rel="bookmark" class="crp_title">Native Drag and Drop</a></li><li><a href="http://html5doctor.com/your-questions-answered-9/" rel="bookmark" class="crp_title">Your Questions Answered 9</a></li><li><a href="http://html5doctor.com/why-designers-should-care-about-html5/" rel="bookmark" class="crp_title">Why designers should care about HTML5</a></li><li><a href="http://html5doctor.com/designing-a-blog-with-html5/" rel="bookmark" class="crp_title">Designing a blog with html5</a></li><li><a href="http://html5doctor.com/your-questions-answered-4/" rel="bookmark" class="crp_title">Your Questions Answered #4</a></li></ul></div></p>

<p>Share and Save:</p>

<pre><code>&lt;a rel="nofollow"  href="http://twitter.com/home?status=Accessibility%20%26%20Native%20Drag%20and%20Drop%20-%20http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F" title="Twitter"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;title=Accessibility%20%26%20Native%20Drag%20and%20Drop&amp;amp;bodytext=A%20few%20days%20before%20my%20native%20drag%20and%20drop%20article%20came%20out%20Gez%20Lemon%20wrote%20about%20accessibility%20in%20drag%20and%20drop%2C%20and%20touched%20on%20HTML%205.%20I%20then%20promised%20to%20look%20at%20implementing%20accessibility%20with%20native%20drag%20and%20drop%2C%20and%20here%27s%20my%20findings." title="Digg"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;amp;m=submit&amp;amp;link=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F" title="Sphinn"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;title=Accessibility%20%26%20Native%20Drag%20and%20Drop" title="Reddit"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;title=Accessibility%20%26%20Native%20Drag%20and%20Drop&amp;amp;notes=A%20few%20days%20before%20my%20native%20drag%20and%20drop%20article%20came%20out%20Gez%20Lemon%20wrote%20about%20accessibility%20in%20drag%20and%20drop%2C%20and%20touched%20on%20HTML%205.%20I%20then%20promised%20to%20look%20at%20implementing%20accessibility%20with%20native%20drag%20and%20drop%2C%20and%20here%27s%20my%20findings." title="del.icio.us"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;title=Accessibility%20%26%20Native%20Drag%20and%20Drop" title="StumbleUpon"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F" title="Technorati"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.netvibes.com/share?title=Accessibility%20%26%20Native%20Drag%20and%20Drop&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F" title="Netvibes"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;t=Accessibility%20%26%20Native%20Drag%20and%20Drop" title="Facebook"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;title=Accessibility%20%26%20Native%20Drag%20and%20Drop&amp;amp;annotation=A%20few%20days%20before%20my%20native%20drag%20and%20drop%20article%20came%20out%20Gez%20Lemon%20wrote%20about%20accessibility%20in%20drag%20and%20drop%2C%20and%20touched%20on%20HTML%205.%20I%20then%20promised%20to%20look%20at%20implementing%20accessibility%20with%20native%20drag%20and%20drop%2C%20and%20here%27s%20my%20findings." title="Google Bookmarks"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.friendfeed.com/share?title=Accessibility%20%26%20Native%20Drag%20and%20Drop&amp;amp;link=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F" title="FriendFeed"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;t=Accessibility%20%26%20Native%20Drag%20and%20Drop" title="HackerNews"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;amp;url=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;title=Accessibility%20%26%20Native%20Drag%20and%20Drop&amp;amp;source=HTML5+Doctor+helping+you+implement+HTML5+today&amp;amp;summary=A%20few%20days%20before%20my%20native%20drag%20and%20drop%20article%20came%20out%20Gez%20Lemon%20wrote%20about%20accessibility%20in%20drag%20and%20drop%2C%20and%20touched%20on%20HTML%205.%20I%20then%20promised%20to%20look%20at%20implementing%20accessibility%20with%20native%20drag%20and%20drop%2C%20and%20here%27s%20my%20findings." title="LinkedIn"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.newsvine.com/_tools/seed&amp;amp;save?u=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;h=Accessibility%20%26%20Native%20Drag%20and%20Drop" title="NewsVine"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /&gt;&lt;/a&gt;
&lt;a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;amp;u=http%3A%2F%2Fhtml5doctor.com%2Faccessibility-native-drag-and-drop%2F&amp;amp;t=Accessibility%20%26%20Native%20Drag%20and%20Drop&amp;amp;s=A%20few%20days%20before%20my%20native%20drag%20and%20drop%20article%20came%20out%20Gez%20Lemon%20wrote%20about%20accessibility%20in%20drag%20and%20drop%2C%20and%20touched%20on%20HTML%205.%20I%20then%20promised%20to%20look%20at%20implementing%20accessibility%20with%20native%20drag%20and%20drop%2C%20and%20here%27s%20my%20findings." title="Tumblr"&gt;&lt;img src="http://html5doctor.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /&gt;&lt;/a&gt;
</code></pre>

<p>&lt;br/>&lt;br/></p>
<p><a href="http://html5doctor.com/accessibility-native-drag-and-drop/" rel="bookmark">Accessibility &#038; Native Drag and Drop</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 23, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/accessibility-native-drag-and-drop/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Native Drag and Drop</title>
		<link>http://html5doctor.com/native-drag-and-drop/</link>
		<comments>http://html5doctor.com/native-drag-and-drop/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 09:00:13 +0000</pubDate>
		<dc:creator>Remy Sharp</dc:creator>
				<category><![CDATA[JavaScript APIs]]></category>
		<category><![CDATA[draganddrop]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=397</guid>
		<description><![CDATA[
			
				
			
		
Along with an army of JavaScript APIs, HTML 5 comes with a Drag and Drop (DnD) API that brings native DnD support to the browser making it much easier to code up.  
HTML 5 DnD is based on Microsoft&#8217;s original implementation which was available as early as Internet Explorer 5!  Now currently supported [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;source=html5doctor&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>Along with an army of JavaScript APIs, <abbr>HTML</abbr> 5 comes with a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#dnd">Drag and Drop</a> (<abbr title="Drag and Drop as referred to in the HTML5 specs">DnD</abbr>) API that brings native DnD support to the browser making it much easier to code up.  </p>
<p><abbr>HTML</abbr> 5 <abbr title="Drag and Drop">DnD</abbr> is based on Microsoft&#8217;s original implementation which was available as early as Internet Explorer 5!  Now currently supported in <abbr>IE</abbr>, Firefox 3.5 and Safari 4.</p>
<p>We&#8217;re going to look how to implement <abbr title="Drag and Drop">DnD</abbr> and review some of the issues (or hoops we have to jump through) with the current implementations now.</p>
<p><span id="more-397"></span></p>
<h2 id="my_first_drag_and_drop">My First Drag and Drop</h2>
<p>DnD requires only a few things to work:</p>
<ul>
<li>Something to drag</li>
<li>A drop target</li>
<li>JavaScript event handlers on the target to tell the browser it can drop</li>
</ul>
<p>The following elements are draggable by default: <code>&lt;img&gt;</code> elements and <code>&lt;a&gt;</code> elements (with an href).</p>
<p>If you want to drag a different element, you need to set the <code>draggable</code> attribute to <code>true</code>. That&#8217;s according to the spec, but to get it to work in Safari and Firefox there&#8217;s a little more that you need to do, which we&#8217;ll come on to.</p>
<p>If you want to skip the code walk through, here&#8217;s the <a href="http://jsbin.com/ezuke">simple drag and drop</a> (<a href="http://jsbin.com/ezuke/edit">source code</a>)</p>
<p>Here&#8217;s our example markup:</p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=utf-8 /&gt;
&lt;title&gt;Basic Drag and Drop&lt;/title&gt;
&lt;style&gt;
#drop {
  min-height: 100px;
  width: 200px;
  border: 3px dashed #ccc;
  margin: 10px;
  padding: 10px;
}
p {
  margin: 3px 0;
}
&lt;/style&gt;
&lt;script src=&quot;http://html5demos.com/h5utils.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;img src=&quot;http://twivatar.org/rem&quot; alt=&quot;Remy Sharp&quot; /&gt;
  &lt;img src=&quot;http://twivatar.org/brucel&quot; alt=&quot;Bruce Lawson&quot; /&gt;
  &lt;img src=&quot;http://twivatar.org/Rich_Clark&quot; alt=&quot;Rich Clark&quot; /&gt;
  &lt;div id=&quot;drop&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p><small>Note: the included <a href="http://html5demos.com/h5utils.js">h5utils.js</a> script is a small library to trigger <abbr>HTML</abbr> 5 elements and to give me cross browser event binding.</small></p>
<p>Currently the <code>&lt;img&gt;</code> elements can be dragged, but they can&#8217;t be dropped (this is the browser&#8217;s default).</p>
<p>To <em>drop</em> elements we need to:</p>
<ol>
<li>Tell the browser that the element can be dragged over a specific point</li>
<li>Handle the drop event</li>
</ol>
<p>To tell the browser we <em>can</em> drop in this element, all we have to do is cancel the <code>dragover</code> event.  However, since <abbr>IE</abbr> behaves differently, we need to do the same thing for the <code>dragenter</code> event.</p>
<p>Here&#8217;s the code for basic drop handling:</p>
<pre><code>var drop = document.querySelector(&#x27;#drop&#x27;);

// Tells the browser that we *can* drop on this target
addEvent(drop, &#x27;dragover&#x27;, cancel);
addEvent(drop, &#x27;dragenter&#x27;, cancel);

addEvent(drop, &#x27;drop&#x27;, function (event) {
  // stops the browser from redirecting off to the text.
  if (event.preventDefault) {
    event.preventDefault();
  }

  this.innerHTML += &#x27;&lt;p&gt;&#x27; + event.dataTransfer.getData(&#x27;Text&#x27;) + &#x27;&lt;/p&gt;&#x27;;

  return false;
});

function cancel(event) {
  if (event.preventDefault) {
    event.preventDefault();
  }
  return false;
}</code></pre>
<p><small>Note for this code, I&#8217;m using <code>addEvent</code> where you&#8217;d normally see <code>element.addEventListener</code>, it&#8217;s from the <a href="http://html5demos.com/h5utils.js">h5utils.js</a> library to support <abbr>IE</abbr>.</small></p>
<p>In the JavaScript we are:</p>
<ol>
<li>Searching for the drop target in the <abbr>DOM</abbr> using <code>document.querySelector</code> (which returns the first result only)</li>
<li>When <code>dragover</code> event is fired (when the user drags the element over another), it will trigger the function called &#8216;cancel&#8217; (at the bottom of the code above) which will prevent the default browser action</li>
<li>Do the same for <code>dragenter</code> to support <abbr>IE</abbr></li>
<li>Bind the <code>drop</code> event, and within there grab some data about what was dropped.</li>
</ol>
<h3 id="dragover_dragenter">dragover &amp; dragenter</h3>
<p>By cancelling this event, we&#8217;re telling the browser <em>this</em> element that we&#8217;re over is the one you can release and drop upon.</p>
<p>I&#8217;m still not entirely sure why there&#8217;s a difference here, but Firefox and friends needs <code>preventDefault</code> on the event, and <abbr>IE</abbr> requires the <code>return false</code>.  Note that the examples out in the wild that use inline JavaScript (yuk, bad), the <code>preventDefault</code> is supposed to be implicit, so you won&#8217;t see it in the code.</p>
<h3 id="drop">drop</h3>
<p>To show what was dropped, we need to do two things:</p>
<ol>
<li>Cancel the default browser action. This is to ensure that if we drop a link, the browser doesn&#8217;t go off and surf to that location</li>
<li>Get the contents out of the <code>dataTransfer</code> object</li>
</ol>
<p>The cancelling of the browser default is, again, done using the <code>preventDefault</code> <em>and</em> <code>return false</code>.</p>
<p>If we don&#8217;t set the <code>dataTransfer</code> data manually (which I&#8217;ll show you later), the default key is set to <em>Text</em>.  So this might be the value of an href of an <code>&lt;a&gt;</code> element, or it might be <code>&lt;img&gt;</code> src address.</p>
<h2 id="doing_more_with_drag8217n_drop">Doing More with Drag&#8217;n Drop</h2>
<p>There&#8217;s a number of extra bits in the spec other than just dragging images.</p>
<p>Here&#8217;s a few bits that I can see being useful:</p>
<ol>
<li>Being able to drag <em>any</em> element</li>
<li>More complex data types, other than text</li>
<li>Set a different drag icon/image when dragging the element</li>
</ol>
<h3 id="dragging_anything">Dragging Anything</h3>
<p>If we change the <code>&lt;img&gt;</code> to <code>&lt;div&gt;</code> tags with background images, I still want to be able to drag them around the page, and drop them in to my container.</p>
<p>The <abbr>HTML</abbr> 5 spec says it should be as simple as adding the following attributes to the markup of the elements in question:</p>
<pre><code>draggable="true"</code></pre>
<p>However, this doesn&#8217;t work completely for Safari or Firefox.  </p>
<p>For Safari you need to add the following style to the element:</p>
<pre><code>[draggable=true] {
  -khtml-user-drag: element;
}</code></pre>
<p>This will start working in Safari, and as you drag it will set a default, empty value with the <code>dataTransfer</code> object.  <em>However</em>, Firefox won&#8217;t allow you to drag the element unless you manually set some data to go with it.</p>
<p>To solve this, we need a <code>dragstart</code> event handler, and we&#8217;ll give it some data to be dragged around with:</p>
<pre><code>var dragItems = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) {
  addEvent(dragItems[i], 'dragstart', function (event) {
    // store the ID of the element, and collect it on the drop later on
    event.dataTransfer.setData('Text', this.id);
  });
}</code></pre>
<p>Here&#8217;s a working demo of <a href="http://jsbin.com/uzovu">drag and drop <em>anything</em></a> (<a href="http://jsbin.com/uzovu/edit">source code</a>)</p>
<h3 id="more_complex_data_types">More Complex Data Types</h3>
<p>You&#8217;ve already seen how we can use <code>dataTransfer.setData(<em>format</em>, <em>string</em>)</code> to associate some data in the example above. </p>
<p>You can also use this key/value pair to store more data, but you&#8217;re limited to storing strings only.</p>
<p>One way I would get around this is to have a data lookup, where the key of the lookup may be the ID of the element, and then I can de-reference the data on the drop event.</p>
<p>For example:</p>
<pre><code>var people = {
  rem : {
    name : "Remy Sharp",
    blog : "http://remysharp.com"
  },
  brucel : {
    name : "Bruce Lawson",
    blog : "http://brucelawson.co.uk"
  }
  // etc...
}

var dragItems = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) {
  addEvent(dragItems[i], 'dragstart', function (event) {
    // store the ID of the element, and collect it on the drop later on
    event.dataTransfer.setData('Text', this.id);
  });
}

addEvent(drop, &#x27;drop&#x27;, function (event) {
  // stops the browser from redirecting off to the text.
  if (event.preventDefault) {
    event.preventDefault();
  }

  var person = people[event.dataTransfer.getData(&#x27;Text&#x27;)];

  this.innerHTML += &#x27;&lt;p&gt;&lt;a href=&quot;&#x27; + person.blog + &quot;&gt;' + person.name + '&lt;/a&gt;&lt;/p&gt;&#x27;;

  return false;
});</code></pre>
<p>Here&#8217;s a working demo of <a href="http://jsbin.com/afica">drag and drop with associated data</a> (<a href="http://jsbin.com/afica/edit">source code</a>)</p>
<p>Obviously this isn&#8217;t the most ideal situation, but there&#8217;s also the possibility to set other content types in the drag data, which should produce some interesting apps in the future.</p>
<h3 id="drag_icon">Drag Icon</h3>
<p>Along with several other options with the <code>dragstart</code> event, you can also set a drag image, i.e. what you see under your cursor.</p>
<p>You can create a <abbr>DOM</abbr> fragment, and then associate the fragment with the <code>dataTransfer</code> using <code>setDragImage(<em>element</em>, <em>x</em>, <em>y</em>)</code>.</p>
<p>So we can add the following to our example to use a custom drag image:</p>
<pre><code>var dragIcon = document.createElement('img');
dragIcon.src = 'http://twivatar.org/twitter/mini';</code></pre>
<p>Which creates an image element, and how within the <code>dragstart</code> event, we&#8217;ll set the drag image:</p>
<pre><code>addEvent(dragItems[i], 'dragstart', function (event) {
  // store the ID of the element, and collect it on the drop later on
  event.dataTransfer.setData('Text', this.id);
  <strong>event.dataTransfer.setDragImage(dragIcon, -10, -10);</strong>
  return false;
});</code></pre>
<p>This sets the custom drag icon 10 pixels below the cursor, as seen in this example: <a href="http://jsbin.com/ijeza">drag and drop with custom image</a> (<a href="http://jsbin.com/ijeza">source code</a>)</p>
<h2 id="native_drag">Native Drag</h2>
<p>There&#8217;s lots of Drag and Drop JavaScript libraries available, but what <em>I&#8217;d</em> like to see, is native <abbr title="Drag and Drop">DnD</abbr> support falling back to library based.  However, I know for a fact that some libraries, including jQuery, construct a custom event when passed in to the event handler which means, <em>currently</em>, you can&#8217;t use the <code>dataTransfer</code> object, so you&#8217;ll have to rely on binding the events yourself.  I&#8217;m sure this will change soon.</p>
<p>There&#8217;s lots more in Drag and Drop but this should be enough to go and play with now!</p>
<p>As for me, I'll be updating the Drag and Drop demos on <a href="http://html5demos.com">HTML5demos.com</a> to see if I can add ARIA support and capture a screencast of it running.  Watch this space!</p>
<h2 id="further_reader">Further Reader</h2>
<ul>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#dnd">HTML5 Drag and Drop spec</a></li>
<li><a href="http://html5demos.com/drag">Alternative demo</a></li>
<li><a href="http://html5demos.com/drag-anything">Demo showing different content types in drag and drop</a></li>
<li><a href="http://www.whatwg.org/demos/2008-sept/dnd/dnd.html">Inline event handles</a></li>
<li><a href="http://dev.opera.com/articles/view/accessible-drag-and-drop/">Accessible Drag and Drop</a></li>
</ul>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul>
<li><a href="http://html5doctor.com/accessibility-native-drag-and-drop/" rel="bookmark" class="crp_title">Accessibility &#038; Native Drag and Drop</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-9/" rel="bookmark" class="crp_title">Your Questions Answered 9</a></li>
<li><a href="http://html5doctor.com/designing-a-blog-with-html5/" rel="bookmark" class="crp_title">Designing a blog with html5</a></li>
<li><a href="http://html5doctor.com/your-questions-answered-8/" rel="bookmark" class="crp_title">Your Questions Answered #8</a></li>
<li><a href="http://html5doctor.com/why-designers-should-care-about-html5/" rel="bookmark" class="crp_title">Why designers should care about HTML5</a></li>
</ul>
</div>
<p>Share and Save:</p>
<p>	<a rel="nofollow"  href="http://twitter.com/home?status=Native%20Drag%20and%20Drop%20-%20http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F" title="Twitter"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;title=Native%20Drag%20and%20Drop&amp;bodytext=Along%20with%20an%20army%20of%20JavaScript%20APIs%2C%20HTML%205%20comes%20with%20a%20Drag%20and%20Drop%20%28DnD%29%20API%20that%20brings%20native%20DnD%20support%20to%20the%20browser%20making%20it%20much%20easier%20to%20code%20up.%20%20%0D%0A%0D%0AHTML%205%20DnD%20is%20based%20on%20Microsoft%26%238217%3Bs%20original%20implementation%20which%20was%20availab" title="Digg"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F" title="Sphinn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;title=Native%20Drag%20and%20Drop" title="Reddit"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;title=Native%20Drag%20and%20Drop&amp;notes=Along%20with%20an%20army%20of%20JavaScript%20APIs%2C%20HTML%205%20comes%20with%20a%20Drag%20and%20Drop%20%28DnD%29%20API%20that%20brings%20native%20DnD%20support%20to%20the%20browser%20making%20it%20much%20easier%20to%20code%20up.%20%20%0D%0A%0D%0AHTML%205%20DnD%20is%20based%20on%20Microsoft%26%238217%3Bs%20original%20implementation%20which%20was%20availab" title="del.icio.us"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;title=Native%20Drag%20and%20Drop" title="StumbleUpon"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F" title="Technorati"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Native%20Drag%20and%20Drop&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F" title="Netvibes"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;t=Native%20Drag%20and%20Drop" title="Facebook"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;title=Native%20Drag%20and%20Drop&amp;annotation=Along%20with%20an%20army%20of%20JavaScript%20APIs%2C%20HTML%205%20comes%20with%20a%20Drag%20and%20Drop%20%28DnD%29%20API%20that%20brings%20native%20DnD%20support%20to%20the%20browser%20making%20it%20much%20easier%20to%20code%20up.%20%20%0D%0A%0D%0AHTML%205%20DnD%20is%20based%20on%20Microsoft%26%238217%3Bs%20original%20implementation%20which%20was%20availab" title="Google Bookmarks"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Native%20Drag%20and%20Drop&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F" title="FriendFeed"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;t=Native%20Drag%20and%20Drop" title="HackerNews"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;title=Native%20Drag%20and%20Drop&amp;source=HTML5+Doctor+helping+you+implement+HTML5+today&amp;summary=Along%20with%20an%20army%20of%20JavaScript%20APIs%2C%20HTML%205%20comes%20with%20a%20Drag%20and%20Drop%20%28DnD%29%20API%20that%20brings%20native%20DnD%20support%20to%20the%20browser%20making%20it%20much%20easier%20to%20code%20up.%20%20%0D%0A%0D%0AHTML%205%20DnD%20is%20based%20on%20Microsoft%26%238217%3Bs%20original%20implementation%20which%20was%20availab" title="LinkedIn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;h=Native%20Drag%20and%20Drop" title="NewsVine"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml5doctor.com%2Fnative-drag-and-drop%2F&amp;t=Native%20Drag%20and%20Drop&amp;s=Along%20with%20an%20army%20of%20JavaScript%20APIs%2C%20HTML%205%20comes%20with%20a%20Drag%20and%20Drop%20%28DnD%29%20API%20that%20brings%20native%20DnD%20support%20to%20the%20browser%20making%20it%20much%20easier%20to%20code%20up.%20%20%0D%0A%0D%0AHTML%205%20DnD%20is%20based%20on%20Microsoft%26%238217%3Bs%20original%20implementation%20which%20was%20availab" title="Tumblr"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
<p><a href="http://html5doctor.com/native-drag-and-drop/" rel="bookmark">Native Drag and Drop</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 9, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/native-drag-and-drop/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
	</channel>
</rss>
