Technology

How to Remove the Dotted Line Around Links

Learn how to remove the dotted outline around links in Internet Explorer and Firefox to meet aesthetic or design requests using CSS and JavaScript methods.

Sangrak

Internet Explorer and Firefox add a dotted outline around links, which might need to be removed for aesthetic reasons or based on a website designer's request. There are three methods to achieve this.

Two involve CSS, and the third uses JavaScript.

Works in IE9, Firefox (CSS)

a:active { outline: none; }

Works in IE6, IE7, IE8 (CSS)

a {selector-dummy: expression(this.hideFocus=true);}

Works in All Browsers (JavaScript)

function bluring(){
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;

The third method, using JavaScript, redirects focus to the body element when an a or img tag is accessed, potentially affecting keyboard accessibility. The most commonly used methods are the first and second due to their greater compatibility and less impact on accessibility.

More on this topic