Is tabIndex: 0 in links is considered good practice to avoid href = "javascript: void (0);"?

a href="javascript: void(0)" is considered bad practice , and I cannot use href="#" in each case, so I am thinking of adding an empty a with tabIndex=0 to be accessible from the keyboard.

Is this a good practice?

PS The Bootstrap popup window requires <a> in the internal elements to navigate the keyboard, so I have to use <a> .

+5
source share
1 answer

Tabindex = 0 will make your links orientable, but not clickable. Instead of using # use the id attribute of the element that changes or that you are transitioning to. For instance. <a href="#section2">Step 2</a> or the like. Thus, you get href so that the link is both customizable and functional, and when this link is clicked, the browser will send the user to this place.

0
source

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


All Articles