Questions tagged [tabindex]

The [tabindex] is used to define a sequence that users follow when they use the Tab key to navigate through a page. By default, the natural tabbing order will match the source order in the markup.

The tabindex content attribute allows authors to control whether an element is supposed to be focusable, whether it is supposed to be reachable using sequential focus navigation, and what is to be the relative order of the element for the purposes of sequential focus navigation. The name "tab index" comes from the common use of the "tab" key to navigate through the focusable elements. The term "tabbing" refers to moving forward through the focusable elements that can be reached using sequential focus navigation.
W3C Recommendation: HTML5
Section 7.4.1 Sequential focus navigation and the tabindex attribute

The tabindex starts at 0 or any positive whole number and increments upward. It's common to see the value 0 avoided because in older versions of Mozilla and IE, the tabindex would start at 1, move on to 2, and only after 2 would it go to 0 and then 3. The maximum integer value for tabindex is 32767. If elements have the same tabindex then the tabindex will match the source order in the markup.

A negative value (usually tabindex="-1") will remove the element from the tab index and it will never be focusable via keyboard navigation. Focus can be given to the element programmatically using element.focus() or with mouse click for focusable elements.

If you specify the tabindex attribute with no value or an empty value it will be ignored.

If the disabled attribute is set on an element which has a tabindex, the element will be ignored.


If a tabindex is set anywhere within the page regardless of where it is in relation to the rest of the code (it could be in the footer, content area, where-ever) if there is a defined tabindex then the tab order will start at the element which is explicitly assigned the lowest tabindex value above 0. It will then cycle through the elements defined and only after the explicit tabindex elements have been tabbed through, will it return to the beginning of the document and follow the natural tab order.


In the HTML4 spec only the following elements support the tabindex attribute: , , , , , , and . But the HTML5 spec, with accessibility in mind, allows all elements to be assigned tabindex.

--

For example

<ul tabindex="-1">
  <li tabindex="0"></li>
  <li tabindex="1"></li>
  <li tabindex="2"></li>
</ul>

is the same as

<ul tabindex="-1">
  <li tabindex="1"></li>
  <li tabindex="1"></li>
  <li tabindex="1"></li>
</ul>

because regardless of the fact that they are all assigned tabindex="1", they will still follow the same order, the first one is first, and the last one is last. This is also the same..

<div>
  <a></a>
  <a></a>
  <a></a>
</div>

because you do not need to explicitly define the tabIndex if it's default behavior. A div by default will not be focusable, the anchor tags will.

512 questions
22
votes
1 answer

Javascript/JQuery remove from tabindex

On an HTML form I have INPUT text box followed by a link, then followed by another INPUT text box. I want to remove the link from the tabindex / tab order:

leepowers
  • 37,828
  • 23
  • 98
  • 129
20
votes
2 answers

TabIndex vs. KeyboardNavigation.TabIndex in WPF

What is the difference between TabIndex and KeyboardNavigation.TabIndex in WPF? When to use each?
Strider007
  • 4,615
  • 7
  • 25
  • 26
20
votes
3 answers

How to debug tabindex

Are there any tools or plugins for web browser to debug tabindex functionality? It seems that tabindex attributes are correct but it behaves not as expected. Or do I do something wrong?
Artsiom Anisimau
  • 1,139
  • 3
  • 11
  • 26
18
votes
3 answers

DockPanel Tab Order

I have a DockPanel set up in the DataTemplate of an ItemsControl as below:
NickAldwin
  • 11,584
  • 12
  • 52
  • 67
17
votes
1 answer

Setting tab index usefully when some fields are hidden by CSS (in an accordion container)

I am trying to make a large form more friendly. There are a number of fields which are used in special cases and these are hidden inside an accordion container with links to expose them if desired. However (at least in Chrome) if you tab through…
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139
17
votes
6 answers

focus on next tabindex of HTML element onEnter keypress by JQuery

Hi Friends, I'm working on a small task which is to enable the user to tabindex the html element upon enter keypress. As im new to jquery , I have written some code which seems to me that It will work ,but there are some problems in it. Initial…
DayTimeCoder
  • 4,294
  • 5
  • 38
  • 61
15
votes
4 answers

find element based on tabindex

Using jquery or javascript, how can I find the input element in the DOM that has a particular tabindex set to it, eg. I would want this element returned if I was searching for the element…
amateur
  • 43,371
  • 65
  • 192
  • 320
15
votes
6 answers

Strange border on tabIndex on

element

I'm currently trying to make some show/hide content more accessible on a large site (in excess of 30,000 pages) and I've come across a weird bug when adding tabindex where a dotted border appears when clicking on the control to open the hidden…
redroot
  • 614
  • 2
  • 7
  • 17
15
votes
2 answers

How to float elements right and still keep tabindex?

Here is a fiddle: http://jsfiddle.net/5s7vv/ What I want to do is have 2 buttons floated left and 2 right, just like the example, but button_4 should be the rightmost element. However, I cannot achieve that by just a simple float right. I should…
NoBBy
  • 497
  • 4
  • 15
15
votes
6 answers

Chrome Extension - first link is auto-focused in popup

How do I stop my Google Chrome extension's default action to auto-focus the first link in my popup.html? I know I could probably do some roundabout hack with JS or change the :focus CSS, but I think this is throwing off something else I'm trying to…
Ryan Grush
  • 2,076
  • 3
  • 37
  • 64
12
votes
3 answers

Simplest way to tab only through focusable descendants of a particular element?

Let's say I have a document full of focusable elements, either because they are innately focusable (like ) or because they have tabindex="0" or the like. Now let's say there's a section of my document that I want to display as a…
Chris Calo
  • 7,518
  • 7
  • 48
  • 64
12
votes
4 answers

Submit button not focused even though tabindex is properly set

I have defined tab index for the input fields in a form. When tabbing through the input fields the submit button is never getting the focus, some other input fields in a different form on the page gets the focus. Those are all having tab indexes…
Nicsoft
  • 3,644
  • 9
  • 41
  • 70
12
votes
3 answers

Find next closest focusable element using jquery?

I want my text boxes have the feature that every time users press enter, it will focus to next closest element whatsoever they are(input, checkbox, button, radio, select, a, div) as long as they can be focused. How can I do that using jquery?
sadcat
  • 131
  • 1
  • 1
  • 3
10
votes
3 answers

Modal with tabindex="-1" gets focus on tab

I'm working with Twitter Bootstrap at the moment, and I'm encountering a strange problem in the tabindex of a modal: I'm trying to tab through the form elements inside the modal, but after the last button the focus disappeared before coming back to…
Stephan Muller
  • 27,018
  • 16
  • 85
  • 126
10
votes
4 answers

Tab index does not work with controls in panels?

I have a vb.net windows form with about 15 comboboxes and 15 textboxes, along with several other controls. All of these TextBoxes and ComboBoxes are located in panels. The reason for this is I need to adjust the visible property of controls based…
TypeM1smatch
  • 225
  • 3
  • 7
  • 15
1
2
3
34 35