Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I click on a link, most browsers draw a dotted box around it. How can I prevent this?

Tags:

html

css

When I click on a link, most browsers draw a dotted box around it. It's easiest to see if the link is opened in a new window, since the original page sticks around.

Can this be stopped?

like image 660
mike Avatar asked Apr 10 '09 17:04

mike


People also ask

What are those different browser that will use to support HTML?

HTML5 is now compatible with all popular browsers (Chrome, Firefox, Safari, IE9, and Opera) and with the introduction of DOCTYPE, it is even possible to have a few HTML features in older versions of Internet Explorer too.

Why is CSS different in Web browsers?

It look different because each browser has his own CSS style defined. This styles apply to the HTML markup when no other CSS is defined inline or comes from an external CSS file.


3 Answers

Put this in your CSS

-moz-outline: none;
outline: none;

Here's a more detailed breakdown and a related question

like image 135
John Sheehan Avatar answered Sep 19 '22 22:09

John Sheehan


http://css-tricks.com/removing-the-dotted-outline/

better use:

a:active {   
    outline: none;
}

or

a { 
    outline: none;
} 

it's more specific. otherwise you might suppress too many things at once. and if you care for accessibility make sure to give the users who can't use a mouse some other way of knowing which link is active or focused.

like image 45
markus Avatar answered Sep 18 '22 22:09

markus


One option is to use the javascript blur function on the link after it's been clicked. The blur function removes focus off the link so it won't be drawn with that dotted box around it.

If you're using jQuery, then you could implement such a solution like this:

$(function() {
    $('a').click(function() {
        $(this).blur();
    });
});
like image 24
Ken Browning Avatar answered Sep 21 '22 22:09

Ken Browning