Removing or disabling browser focus border through javascript

Does anyone know how to disable or process (in most browsers) the dashed border of a dom element if it has focus in tabindex order?

I want to create my own style for a focused element, but it would be great to use an existing function, because with tabindex you can bind the keydown event to the dom element.

+47
javascript html css tabindex
Jun 10 2018-10-10
source share
7 answers

Just create a CSS rule for the elements you want to have outline:none;

+114
Jun 10 '10 at 2:58 p.m.
source share
— -

CSS trick:

 :focus { outline: none; } 
+25
Sep 05 '10 at 18:29
source share
 a { outline: 0; } a: hover, a: active, a: focus { outline: none; } input::-moz-focus-inner { border: 0; } 
+1
Dec 29 '13 at 5:44
source share

With Firefox 53.0, if I disable the scheme with one of the suggested solutions, Firefox will display by default.

However, if I use an empty color, it does not detect that the outline is hidden:

 input:focus{ outline: 1px solid rgba(255,255,255,1); } 
+1
May 10 '17 at 12:33 a.m.
source share
 input::-moz-focus-inner { border: 0; } 
0
Jun 29 '10 at 9:35 a.m.
source share

:focus state - set the contour property to transparent 0px;

0
Jun 28 '16 at 6:45
source share

Using jQuery you can do

 $("#nav li a").focus(function(){ $(this).blur(); }); 
-6
Jun 10 2018-10-10
source share



All Articles