DEV Community

Discussion on: Need to set tabIndex=0 to enable tab navigation

Collapse
 
taylormsj profile image
Taylor Mitchell-St.Joseph

One thing comes to mind -
If you use a tabindex greater than 0 then you run the risk of disrupting the tab order.
Tabbing through the following example would navigate you from the first to the third back to the second, which in most cases isn't what you would want.

<input tabindex="1" />
<input tabindex="3" />
<input tabindex="2" />
Enter fullscreen mode Exit fullscreen mode

Keeping everything at 0 would ensure the order remains in a semantic order

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Thank you Taylor.
That makes sense.

How about when a site is responsive, and you need to have a different tab indexes (as layout can change)?

If tabindex is set to 0 everywhere, tabbing might jump around depending on the layout...