<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.mikesmullin.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>posts on &quot;JavaScript&quot;</title>
 <link>http://www.mikesmullin.com/blog/tag/JavaScript</link>
 <description>A list of blog post tags for the current user.</description>
 <language>en</language>
<item>
 <title>Removing the Dotted Outline from Focused Links</title>
 <link>http://www.mikesmullin.com/2006/06/16/removing-the-dotted-outline-from-focused-links</link>
 <description>&lt;p&gt;Have you ever noticed the dotted outline that appears around links as you click on them? That is an accessibility feature for people who can&#039;t use the mouse for whatever reason. It is supposed to show where the current focus is when you use the TAB key to move through a document, and does a fantastic job.&lt;/p&gt;
&lt;img src=&quot;/files/2006/06/dotted-focus-outline.png&quot; alt=&quot;the Dotted Focus Outline&quot; class=&quot;alignright&quot; /&gt;
&lt;p&gt;&lt;strong&gt;But why does it appear when you are using the mouse to click on a link?&lt;/strong&gt;&lt;/p&gt;
&lt;!--break--&gt;

&lt;p&gt;This naturally subtle visual cue has become a convention across all browsers, gently reassuring the user when they have successfully clicked on a link. Without it, users will try again to click a link thinking they missed it&amp;#8212;and if the server isn&#039;t immediately responsive they assume the browser is frozen and contemplate closing it.&lt;/p&gt;

&lt;p&gt;But for a designer this happens to be particularly annoying on image links, when the dotted focus remains even after you have clicked the link &lt;em&gt;and&lt;/em&gt; moved your mouse away from it.&lt;/p&gt;

&lt;p&gt;While I am an advocate of using JavaScript to remove the dotted focus from links onMouseDown or onMouseOut, but I would not recommend removing the dotted focus entirely. You still need it to be there when people are using the keyboard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember:&lt;/strong&gt; This is an accessibility feature, and people who can&#039;t use the mouse for whatever reason depend on it. You know, people who eat and surf the web, like me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enough banter, show me the code:&lt;/strong&gt;&lt;/p&gt;
&lt;code&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;//&amp;lt;!--
var runOnLoad = new Array(); // for queuing multiple onLoad event functions
window.onload = function() { for(var i=0; i&amp;lt;runOnLoad.length; i++) runOnLoad[i]() }
// hide dotted :focus outlines when mouse is used
// but NOT when tab key is used
if(document.getElementsByTagName)
for(var i in a = document.getElementsByTagName(&#039;A&#039;)) {
&amp;nbsp;&amp;nbsp;a[i].onmousedown = function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.blur(); // most browsers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.hideFocus = true; // ie
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.style.outline = &#039;none&#039;; // mozilla
&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;a[i].onmouseout = a[i].onmouseup = function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.blur(); // most browsers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.hideFocus = false; // ie
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.style.outline = null; // mozilla
&amp;nbsp;&amp;nbsp;}
}
//--&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;

&lt;p&gt;Alternatively, you could remove the dotted outline entirely in favor of a different visual cue. Maybe even one that matches your design. I&#039;ve experimented with color, backgroundColor, and font-size and they were all pretty cool.&lt;/p&gt;</description>
 <comments>http://www.mikesmullin.com/2006/06/16/removing-the-dotted-outline-from-focused-links#comments</comments>
 <category domain="http://www.mikesmullin.com/category/javascript">JavaScript</category>
 <pubDate>Fri, 16 Jun 2006 19:23:37 -0600</pubDate>
 <dc:creator>mikesmullin</dc:creator>
 <guid isPermaLink="false">23 at http://www.mikesmullin.com</guid>
</item>
</channel>
</rss>
