Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove dotted border around active hyperlinks in IE8 with CSS

Active hyperlink texts are highlighted with dotted border. When using effects on such hyperlinks (fadeIn/fadeOut) it produces strange effects. How do I disable/remove the dotted border?

like image 743
glaz666 Avatar asked Jul 17 '09 11:07

glaz666


People also ask

How do I get rid of the dotted outline in CSS?

We can remove the default behavior of hyperlinks which is to show a dotted outline around themselves when active or focused by declaring CSS outline property on active/focused links to be none.

How do I get rid of the dotted border?

Select the cells from which you want to remove the dotted border. Click the Home tab. In the Font group, click on the 'Border' drop-down. In the border options that appear, click on 'No Border'


2 Answers

Try this CSS:

a:active, a:selected, a:visited {      border: none;     outline: none; } 

Note that this has to be after any a:hover rules. Thanks to PEra in the comments for suggesting using the a:selected selector as well.

NOTE

The above does not work in IE 9. Removing a:selected causes it to work in IE9.

like image 112
Lucas Jones Avatar answered Oct 13 '22 00:10

Lucas Jones


Typical and safe way to do it is this:

a:active, a:focus {    outline:  none; /* non-IE */    ie-dummy: expression(this.hideFocus=true); /* IE6-7 */ } 

Since expresssion() has been gutted in IE8, you may need a script:

if (document.documentElement.attachEvent)     document.documentElement.attachEvent('onmousedown',function(){          event.srcElement.hideFocus=true     }); 

If you're going to remove the default focus outline, you must define your own distinct style for :focus, otherwise keyboard users will have a hard time using your site.

like image 34
Kornel Avatar answered Oct 13 '22 01:10

Kornel