CSS: Remove Dotted Outline Border From Active Links

So you’re doing some clever Javascript and you have a link tag tag that you want to act as say a tab or a button, but when you click down on the link you get this ugly dotted border highlighting your selection!

elc technologies - Core.jpg

No good. Spice up your CSS with a little…


outline-style:none;
outline-width:0;

and you’ll be living large with a more “tabular” or “buttonular” feel.

98e2cb11fc777654e1a825bb48d194f1052913ba_1233291631_0

15 Comments

  1. Posted January 30, 2009 at 12:09 pm | Permalink

    Or in 1 line.


    a { outline: 0 none; }

  2. Nathan Bertram
    Posted January 30, 2009 at 2:59 pm | Permalink

    One thing to keep in mind about the outline property is that it is an accessibility feature. When you tab through a web page the purpose of the outline is to show you where your cursor is.

  3. Posted January 30, 2009 at 3:44 pm | Permalink

    Thanks for the comments! Both are great points.

  4. Posted January 30, 2009 at 8:14 pm | Permalink

    Thanks for pointing this out Cary. Those dots were driving me nuts just last week.. didn’t know you could fix it with CSS!

  5. Posted February 3, 2009 at 4:36 am | Permalink

    I would suggest:


    a:active { outline: none;}

    It doesn’t interfere with the accessibility issue mentioned by Nathan.
    I think you can also return false in your click event to avoid the dotted lines

  6. Posted July 12, 2009 at 8:37 pm | Permalink

    t?kler

  7. Posted August 12, 2009 at 12:06 pm | Permalink

    What is the code voor internet explorer? The CSS is only for firefox.

  8. Posted August 13, 2009 at 8:20 pm | Permalink

    A small Google search, your article, a website fixed.
    Thanks :)

  9. Posted August 17, 2009 at 11:39 pm | Permalink

    >> “It doesn’t interfere with the accessibility issue mentioned by Nathan.”

    The :active{} does interfere with keyboard accessibility; at least in modern browsers (e.g. Firefox3, Opera9.5 and IE8)

    There is a JS way to remove the border without destroying usability – or better yet, style that “dotted border”.

    For the guy who wanted the IE6/7 fix, see my write up on the subject: http://haslayout.net/css-tuts/view?tut=Removing-Dotted-Border-on-Clicked-Links

    Cheers

  10. Posted August 26, 2009 at 6:15 pm | Permalink

    I believe I’ve tried around 30 diff codes to eliminate this effect – I would now like to say : “Thank you Dave Shenk !”

  11. Posted August 26, 2009 at 6:16 pm | Permalink

    P.S : Great site boys :)

  12. Posted September 2, 2009 at 5:22 pm | Permalink

    So very, very handy… thanks guys. ELC rawks!

  13. Mircea
    Posted September 10, 2009 at 10:01 pm | Permalink

    Thanks Cary Dunn

  14. Sathya
    Posted October 21, 2009 at 11:49 am | Permalink

    Hey dude, you are fabulous! Never thought a simple line would do that trick. Thanks from a starter! :) Thanks Dave.

  15. okosine
    Posted November 12, 2009 at 10:45 am | Permalink

    Thank You !

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">