<?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>Wed, 16 May 2012 11:31:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>&#8220;Block-level&#8221; links in HTML5</title>
		<link>http://html5doctor.com/block-level-links-in-html-5/</link>
		<comments>http://html5doctor.com/block-level-links-in-html-5/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 12:00:06 +0000</pubDate>
		<dc:creator>Bruce Lawson</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Browser Compatibility]]></category>
		<category><![CDATA[Elements]]></category>
		<category><![CDATA[a]]></category>
		<category><![CDATA[HTML 5]]></category>

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

