<?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>I Love Usability &#187; target area</title>
	<atom:link href="http://iloveusability.com/tag/target-area/feed/" rel="self" type="application/rss+xml" />
	<link>http://iloveusability.com</link>
	<description>Reviews &#38; articles about rock-solid usability and stunning user experiences.</description>
	<lastBuildDate>Sat, 14 Nov 2009 23:14:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Clickable &lt;li&gt;</title>
		<link>http://iloveusability.com/usability-tip/clickable-list-item/</link>
		<comments>http://iloveusability.com/usability-tip/clickable-list-item/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 14:00:22 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Usability Tip]]></category>
		<category><![CDATA[:hover]]></category>
		<category><![CDATA[Fitt's Law]]></category>
		<category><![CDATA[li]]></category>
		<category><![CDATA[target area]]></category>

		<guid isPermaLink="false">http://iloveusability.com/?p=238</guid>
		<description><![CDATA[Increasing the clickable are of links inside your <code>&#60;li></code>'s increases usability.]]></description>
			<content:encoded><![CDATA[<p class="introduction">When designing this site, I set out to make it as simple as possible. I opted to just give you basic post information on the <a href="http://iloveusability.com/">home page</a>. I originally coded the markup to be a table, but discovered a problem when I tried to make the whole row clickable. I ended up with a <em>list</em> of articles instead.</p>
<p>Look at what we&#8217;re going to accomplish in this article:</p>
<ul class="demo group">
<li class="before"><a href="http://iloveusability.com/demo/clickable-li/before/" title="See what the page looked like before this article">Before Demo <em>Table-based</em></a></li>
<li class="after"><a href="http://iloveusability.com/demo/clickable-li/after/" title="See what the page looks like after this article">After Demo <em><code>ul</code> Goodness</em></a></li>
</ul>
<h3>How I Want the Row to Behave</h3>
<p>This is best illustrated with a video example from the new iTunes store.</p>
<p><object width="480" height="420"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7028106&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7028106&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="480" height="420"></embed></object></p>
<p>Notice how you can click anywhere in the row to get the song to play. The hover state lets you know that it is all clickable.</p>
<h3>How The Markup Started</h3>
<p>I started with a table-based list of articles. It was easier to make the design align to my layout grid with a table. I justified the use of the &#8220;HTML element that shall not be named&#8221; by convincing myself that the data was mostly tabular. A column for each category, title, and summary made sense to me.</p>
<p>You can <a href="http://iloveusability.com/demo/clickable-li/before/" alt="Preserved in a glass case">see the original design here</a>. Basically, the markup looked like this:</p>
<pre class="sh_html">
&lt;table class="posts" cellpadding="0" cellspacing="0">
  &lt;colgroup>
    &lt;col id="category" />
    &lt;col id="title" />
    &lt;col id="summary" />
  &lt;/colgroup>

  &lt;tbody>
    &lt;tr>
      &lt;td>
        &lt;a href="#">Usability Review&lt;/a>
      &lt;/td>
      &lt;td>
        &lt;h2>&lt;a href="#">Typekit&lt;/a>&lt;/h2>
      &lt;/td>
      &lt;td>
        &lt;p>Excerpt goes right her'&lt;/p>
      &lt;/td>
    &lt;/tr>
  &lt;/tbody>

&lt;/table>
</pre>
<p>Semantically, this was probably fine, but it felt dirty when I tried making the whole table row a single link. The only way I found to do that involved three separate heavily padded links to the same place and some absolute positioning to make it look good. That created a lot more problems than it solved. After four hours of hacking at different markup and CSS, I decided to try a different approach.</p>
<h3>Converting to an Unordered List</h3>
<p>I thought about what this element really was and it is a <strong>list of articles</strong>, starting with the most recent. I thought to myself:</p>
<blockquote>
<p>If this is a list of articles, why am I using a <code>table</code> to mark it up? It could be done much better with an unordered list (<code>&lt;ul></code>).</p>
</blockquote>
<p>Converting this particular element to a list gives me a warm semantic butterflies in my stomach.</p>
<h4>Semantic Butterflies</h4>
<pre class="sh_html">
&lt;ul class="posts">

  &lt;li id="post-1" class="group">
    &lt;a href="#post">

      &lt;span class="category">Usability Review&lt;/span>
      &lt;strong class="title">Typekit&lt;/strong>
      &lt;em class="excerpt">Web app for embedding custom fonts in your design that will change the way you approach web typography.&lt;/em>

    &lt;/a>
  &lt;/li>

&lt;/ul>
</pre>
<p>This markup isn&#8217;t ideal for two reasons:</p>
<ol>
<li>I&#8217;m using <strong>extra elements</strong> (like the <code>span</code>, <code>strong</code> and <code>em</code>)</li>
<li>I <strong>cannot use my <code>h2</code> element for the post titles</strong> because links cannot surround block-level elements like <code>p</code>s or <code>h2</code>s. I&#8217;m losing some search engines benefits and some semantificity (I just made that word up), but <code>strong</code> is a good substitute.</li>
</ol>
<p>For now, I&#8217;ll have to live with this if I want to make the entire list item a link, but there is some hope for the future. <a href="http://meyerweb.com/eric/thoughts/2008/07/23/any-element-linking-demo/">Eric Meyer proposed any element linking</a> in which you could give any element an <code>href</code> property. Wouldn&#8217;t it be nice to be able to do this in HTML 5?</p>
<pre class="sh_html">
&lt;p href="http://linktosomething.com">This entire paragraph will appear as a clickable link&lt;/p>
</pre>
<p>or</p>
<pre class="sh_html">
&lt;tr href="http://linktosomething.com">
  &lt;td>Every bit&lt;/td>
  &lt;td>in this table row&lt;/td>
  &lt;td>will be clickable&lt;/td>
&lt;/tr>
</pre>
<p>Currently, Eric&#8217;s solution works in a limited number of browsers and uses some inline Javascript to work its magic. Check out the <a href="http://meyerweb.com/eric/html-xhtml/html5-linking-demo.html">demo</a> if you want to see his markup.</p>
<p>There is still hope that any element linking will be easier in the future, but that doesn&#8217;t solve your problem now.</p>
<h3>What Works Now</h3>
<p>Now that we have the markup stashed away and validated (you better be validating, mister!), we can move onto making it look nice with CSS.</p>
<h4>Expanding the Link to Fill the Entire Row</h4>
<p>The most important part of this code is making each link a fill up the entire row. Imagine pouring water into a clear square box. It will naturally expand to fill its container. Our entire goal with this technique is make each post link more usable by increasing the entire clickable area. Currently, only the text is clickable.</p>
<p><img src="http://iloveusability.com/wp-content/uploads/2010/09/one.png" alt="Unstyled markup picking up basic styles from previously declared general anchors" title="" class="alignnone size-full wp-image-289" /></p>
<p>We can make the link act like H<sub>2</sub>O by making each link inside a list item a <code>block</code>. I&#8217;m giving the link a light blue background when it&#8217;s hovered over to let the viewer know the entire row is clickable.</p>
<pre class="sh_css">
ul.posts li a { border: 0; display: block; overflow: hidden; }
ul.posts li a:hover { background-color: #DBF1F9;/* light blue */ }
</pre>
<p>Next, we&#8217;ll float the different pieces of data to where we want them. Categories goes all the way to the left, title in the middle, and post excerpt to the right.</p>
<pre class="sh_css">
ul.posts span.category { float: left; }
ul.posts strong.title { float: left; }
ul.posts em.excerpt { float: right; }
</pre>
<p>Easy enough. There is no <code>float: middle</code> so for the title, we float it left too. It ends up bumping up against the category block keeping it in the center.</p>
<p><img src="http://iloveusability.com/wp-content/uploads/2010/09/two.png" alt="Floated, but not effective because no widths are declared" title="" class="alignnone size-full wp-image-291" /></p>
<p>Floating isn&#8217;t effective because we still need to give each piece of data a width and padding so it has some room to breath. When trying to make something simple and easily scannable, <strong>white space is your friend</strong>.</p>
<pre class="sh_css">
ul.posts span.category { float: left; width: 20.2%; }
ul.posts strong.title { float: left; width: 38.4%; }
ul.posts em.excerpt { float: right; width: 38.4%; }

ul.posts span.category,
ul.posts strong.title,
ul.posts em.excerpt { padding: 3% 1% 2% 0; }
</pre>
<h4>Where the hell did I get those widths?!</h4>
<p>I actually just made them up! The skillful designer in me told me that 38.4% was the way to go.</p>
<p><em>Just kidding.</em> I actually used a mathematical formula to figure it out (and you thought you were done with math in high school). Instead of giving each element a fixed width, I went with a percent to give the design fluidity.</p>
<p>Here&#8217;s how to <strong>convert from a fixed width element to a percentage</strong>:</p>
<ol>
<li>Determine the element&#8217;s desired width (300px for the title) and the width of the containing element (760px).</li>
<li>Divide the desired width by the width of the container. (300px/760px)</li>
<li>Convert that to a percentage. (0.394 is 39.4%)</li>
<li>Subtract any padding (1% on the right)</li>
<li>Ta-da! You have your width in a percentage. (38.4%)</li>
</ol>
<p>I got the width of the containing element by seeing how many columns it spans in my grid system. I use the <a href="http://960.gs/">960 grid system</a> for my layouts. If you&#8217;ve never used a grid system, I recommend trying one out, at least while first laying out your design.</p>
<p><img src="http://iloveusability.com/wp-content/uploads/2010/09/three.png" alt="Basic layout is done giving the data some room to breath" title="" class="alignnone size-full wp-image-290" /></p>
<p>The layout is there and the entire row is clickable (denoted by the blue). We need to style it so it looks pretty (as a designer, I tend to like pretty things).</p>
<h4>Prettifying It</h4>
<p>Let&#8217;s put a border beneath each item, a border at the tippy top of the list for balance, and ditch that bullet point.</p>
<pre class="sh_css">
ul.posts { border-top: 1px solid #ddd; list-style: none; }
ul.posts li { border-bottom: 1px solid #ddd; }
</pre>
<p><img src="http://iloveusability.com/wp-content/uploads/2010/09/four.png" alt="Adding a border to each list item and getting rid of the bullet points" title="" class="alignnone size-full wp-image-288" /></p>
<p>Let&#8217;s add some finishing touches to make attract attention where it is most important. I want viewers to first see the title, so I&#8217;ll make that the darkest and the biggest (basically mimic what an <code>h2</code> normally looks like). If the title strikes their fancy, I want them to read the one sentence excerpt about the post. Lastly, I want them to see the category on the left, so I&#8217;ll make that the lightest.</p>
<pre class="sh_css">
ul.posts span.category { color: #888; color: rgba(0,0,0,0.47); padding: 4% 1% 4% 0; }
ul.posts strong.title { color: #333; color: rgba(0,0,0,0.8); font-size: 42px; font-weight: bold; line-height: 41px; margin: 0; }
ul.posts em.excerpt { color: #555; color: rgba(0,0,0,0.66); font-style: normal; }
</pre>
<p><strong>Note about the <code>rgba</code>:</strong> I like to use <code>rgba</code> when coloring something a shade of gray because it allows me to adjust the visual weight straight from the code. If I want something to be less important (like the category), I&#8217;ll knock its opacity down (the <code>a</code> part of <code>rgba</code>). Once I&#8217;ve found a shade I like, I convert it to a regular hex color so older browsers still color it appropriately.</p>
<p>I put the hex color code first because older browsers will just ignore the <code>rgba</code> if they don&#8217;t understand it. I <em>keep</em> the <code>rgba</code> color there to give modern browsers a bit of snazzy styling. If I had a background color on the whole page (blue for example), the semi-opaque gray text would pick up the slightest hint of blue because the background would show through. Dan Cederholm talks extensively about this subtle visual effect in his new book <a href="http://handcraftedcss.com/">Handcrafted CSS</a>.</p>
<p><img src="http://iloveusability.com/wp-content/uploads/2010/09/five.png" alt="Final product, style and all" title="" class="alignnone size-full wp-image-287" /></p>
<p>We end up with a minimalist and usable clickable list item that uses valid HTML and CSS code. Check out the <a href="http://iloveusability.com/demo/clickable-li/after/">live demo</a> to see the final result in action.</p>
<p>Here&#8217;s the complete CSS code for reference:</p>
<pre class="sh_css">
ul.posts li a { border: 0; display: block; overflow: hidden; }
ul.posts li a:hover { background-color: #DBF1F9;/* light blue */ }

ul.posts span.category { float: left; width: 20.2%; } /* 160/760px - 1% padding */
ul.posts strong.title { float: left; width: 38.4%; } /* 300/760px - 1% padding */
ul.posts em.excerpt { float: right; width: 38.4%; } /* 300/760px - 1% padding */
ul.posts span.category, ul.posts strong.title, ul.posts em.excerpt { padding: 3% 1% 2% 0; }

ul.posts { border-top: 1px solid #ddd; list-style: none; margin-right: 40px; }
ul.posts li { border-bottom: 1px solid #ddd; }
ul.posts span.category { color: #888; color: rgba(0,0,0,0.47); padding: 4% 1% 4% 0; }
ul.posts strong.title { color: #333; color: rgba(0,0,0,0.8); font-size: 42px; font-weight: bold; line-height: 41px; margin: 0; }
ul.posts em.excerpt { color: #555; color: rgba(0,0,0,0.66); font-style: normal; }
</pre>
<p>I tested this code in IE7, IE8, Safari and Firefox (for Mac and Windows).</p>
<script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_html.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_html.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_html.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_html.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_css.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_css.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_css.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_css.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_css.js"></script><script type="text/javascript" src="/wp-content/plugins/shjs-syntax-hiliter/shjs/lang/sh_css.js"></script>]]></content:encoded>
			<wfw:commentRss>http://iloveusability.com/usability-tip/clickable-list-item/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
