jQuery and ASP.NET

August 29, 2009

Prevent a Dotted Border around a Hyperlink when clicked in FireFox




I recently got bumped with a strange Link behavior. A user had a hyperlink which opened in a new page. When she clicked on it, a dotted border appeared around the Hyperlink as shown below:

image

I had seen this behavior a couple of times in the past but never thought of a solution until now. After trying a couple of solutions, what worked out was adding the following CSS to the page:

<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Remove Dotted Border in FireFox</title>
<
style type="text/css">
a:focus {
outline: none;
}
</style>
</
head>
<
body>
<
a href="#" id="anchor1">Click Here</a>
</
body>
</
html>

I have tested the solution in Firefox 3.0 and above and after adding the CSS, the dotted border does not appear anymore when the link is clicked

image



'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

10 Responses to "Prevent a Dotted Border around a Hyperlink when clicked in FireFox"
  1. Chris said...
    August 30, 2009 3:33 PM

    Nice, and so simple. That's something that's always bugged me about Firefox.

  2. Anonymous said...
    August 30, 2009 9:27 PM

    Thanks for this, our current app had this problem in Firefox, this fix works a treat. A minor UI issue, but it makes the app look just that bit more polished. :)

  3. Anonymous said...
    August 30, 2009 9:48 PM

    Please don't do that, it can make it more difficult for users with disabilities to navigate the site without a mouse. Try setting the :focus style to look the same as the hover/active styles so people unable to use a mouse will still have a visual cue to navigate the site. See this:

    http://www.allaccessblogging.com/link-focus.html

  4. Suprotim Agarwal said...
    August 31, 2009 12:55 AM

    Nice suggestion Anonymous and thanks for that link!

    Chris and Anonymous - Glad you found it helpful.

  5. Sumeet Chawla said...
    September 17, 2009 2:30 AM

    Hey, Thanks a ton... This small highlighting border always irritated me a lot :P Thanks you, its gone now ;)

  6. Anonymous said...
    November 24, 2009 2:39 PM

    Sweet!

  7. Zarinand said...
    December 27, 2009 8:04 AM

    Thank you very much - being new to CSS it would have taken me ages to figure out - thanks again :)

  8. Anonymous said...
    April 5, 2010 6:31 PM

    It does appear when I click the above image in my firefox

  9. Mikey said...
    May 25, 2010 2:17 AM

    This WORKS!

    I've been looking for this for DAYS! Only tried 'border' and 'border-style' or specifying the border to 0px, but nothing worked.

    It's clearly the 'outline' value that controls this pesky 1px dotted border!

    One problem - you didn't do it for this tutorial!! Both the 'Click Here' images are styled the same.

    You should apply the 'outline:none' to the second image, so people can see what's changed and that it works. Were I not so keen to try something new, I would have discarded this tutorial as there's no example of it actually working.

    Great solution though! Well done and thank you!!

  10. piyushwalia said...
    September 12, 2011 11:49 AM

    thanx a lot....

 

Copyright © 2009-2011 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions