21

I have a paragraph with various html elements. Some links, some input boxes, etc. The TAB button changes focus from the current element to the next html element: it jumps from link to link. Is it possible to set a specific html element to be "skipped" from such focus from the TAB button?

Randomblue
  • 112,777
  • 145
  • 353
  • 547
  • 1
    Here's a start: http://stackoverflow.com/questions/1561021/prevent-tabstop-on-a-element-anchor-link-in-html – Ethan Shepherd Jul 26 '11 at 00:08
  • Possible duplicate of [How to ignore HTML element from tabindex?](https://stackoverflow.com/questions/5192859/how-to-ignore-html-element-from-tabindex) – RajnishCoder Dec 06 '18 at 13:28

1 Answers1

59

The tabindex attribute controls tabbing. Set it to -1 and the tab key will not stop on that element.

<input tabindex="-1" />

Set it to a non-negative number and you can control the tab order. From the W3C spec:

The following elements support the tabindex attribute: A, AREA, BUTTON, INPUT, OBJECT, SELECT, and TEXTAREA.

In HTML5 you can use the tabindex attribute on any element. From HTML5 differences from HTML4:

Several attributes from HTML4 now apply to all elements. These are called global attributes: accesskey, class, dir, id, lang, style, tabindex and title.

knut
  • 4,699
  • 4
  • 33
  • 43
jfriend00
  • 683,504
  • 96
  • 985
  • 979