Links do not get focus when you click on Chrome

I came across a very strange behavior in Chrome that seems like a mistake to me: when you click on a link, the link does not get focus. Worse, the body focuses instead.

This can be seen here: http://jsfiddle.net/YfbR7/4/ ( see code sample here )

This is mistake? Is this standard behavior? Is there any workaround for links to get focus on the mouse, like on other browsers?

+6
source share
2 answers

Add the index index to the anchor tag that should work, this is not a web dialing error.

 <a href="#" tabindex="1">Click me</a> 
+6
source

In addition to the accepted answer:

Since setting tabindex to 1 would change the behavior of TAB , I recommend setting -1 instead: it will not disrupt TAB navigation and still allow it to focus.

 <a href="#" tabindex="-1">Example</a> 

By the way, here is a very good article regarding these issues.


Note. The same thing happened to me, but only on Safari: perhaps Chrome has already fixed this problem.

+2
source

Source: https://habr.com/ru/post/952347/


All Articles