SHARE
Facebook X Pinterest WhatsApp

No Dotted Line On Links

Written By
thumbnail
Joe Burns
Joe Burns
Jan 4, 2005

So, I’m at this conference and I’ve just finished my presentation when a Goodies reader bops up and asks if there’s any method of losing the dotted line that appears around the active links and active images in the Internet Explorer browser. I didn’t know one off the top of my head, but I told him I’d certainly try to find out. This tutorial is my attempt to “certainly try to find out”.


You’ll find two methods below. The first will allow the dots to pop up for just a moment (my favorite). The second will lose the dots totally.


The dotted line is technically called a “selection rectangle” and it was put there in order to help the user. The rectangle appears when the active text or image has focus brought to it. In layman’s terms, when someone clicks on it.
The rectangle remains as long as focus is upon the element. In fact, the rectangle pretty much stays on the screen even if focus is moved from element to element through tabbing. It makes image maps look cruddy.

The thing is so persistent that it stays surrounding the active text or image even if the user clicks to go to another page and then returns using the BACK button. (You must be using Internet Explorer to see what I’m talking about!) Dig this:

Click Here


Now that you’ve returned, is there still a selection rectangle around the text? Yepper. I thought so. That box won’t go away by itself. You can even try reloading the page.

Now, here’s another link. This link will take you off-site so that the page takes a little longer to change. Notice the selection rectangle this time around.

Click For Another Site


It happened so quickly that some of you might have missed the effect. Click again.


Did you notice that the selection box popped up but only as long as the click itself took to perform? As soon as the click was over, the selection box went away.

Here’s the code that made the second link from up above:

<A HREF=”http://www.vhnd.com”
onClick=”if(navigator.appName == ‘Microsoft Internet Explorer’)this.blur()”>
Click For Another Site</a>

(get it all on one line)

The onClick is what does the trick. It’s a little more than it needs to be because I have it set to test the browser and only react if it’s Internet Explorer. All you really need is the “this.blur()” command. Like so:


<A HREF=”http://www.hairclub.com”
onClick=”this.blur()”>
Click For Another Site</a>

The command is set up so that as soon as the click, the forced focus, is over, focus is taken off of the element and the selection box goes away. The onClick format above can be copied and pasted into a hypertext link no matter if the active area will be text or an image. It works great for image maps.

Lose It Altogether

I actually like the selection rectangle popping up. I just don’t want it to stay. I want it to appear and
leave that fast. Some of you may not want it at all. For that we need a little different coding.
Dig this:

Hair Club for Men

That’s pretty cool, huh? Here’s the code compliments of Derek Petersen at LinuxFreeMail.com:

<a href=http://www.hairclub.com
onFocus=”if(this.blur)this.blur()”>Hair Club for Men</a>


Notice that once focus is brought to the element, the blur is stopped twice.
It’s a double blur! Use this and you’ll get no rectangle at all.


So, to that guy at the conference…I told you I’d find out.


Enjoy!

Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.