<?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; a</title>
	<atom:link href="http://html5doctor.com/tag/a/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>&#8220;Block-level&#8221; links in HTML5</title>
		<link>http://html5doctor.com/block-level-links-in-html-5/</link>
		<comments>http://html5doctor.com/block-level-links-in-html-5/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 12:00:06 +0000</pubDate>
		<dc:creator>Bruce Lawson</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[a]]></category>
		<category><![CDATA[HTML 5]]></category>

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