CSS: Removing dotted outlines on clicked hyperlinks

No matter how much you know about CSS, you can always stumble across something new.

I was pretty much unaware of the “outline” style attribute - which isn’t really a big deal, because in most ways it works the same as the “border” attribute.

Except…

The “outline” attribute is what’s responsible for drawing the little dotted boxes around hyperlinks when they are clicked or navigated (tabbed) to via keyboard (I always thought it was strictly a OS-level effect). Anyway, if they’re a visual blight on your sight, you may be inclined to try this:

a { outline:none }

However, that would make keyboard navigation nearly impossible. Don’t do it. If you just want to avoid them on active (clicked) links, just throw this in your CSS file:

a:hover { outline:none }

And there you go. Huh. Thanks to my pal Matt D. for the tip.

2 Responses to “CSS: Removing dotted outlines on clicked hyperlinks”

Leave a Reply