Making Elements Focusable with Tabindex
"... if we want to capture input from the keyboard, we'll need to use elements that can accept the focus: primarily links and form controls ... "
I quickly thought about simply adding the
tabindex attribute to an element and after some preliminary tests in FF2/Win and IE7/Win it seems that's all that is necessary to make an element focusable.
After some discussion with Derek Featherstone, I learned some interesting stuff (and hopefully I'm describing this accurately).
tabindex value can allow for some interesting behaviour.
- If given a value of "-1", the element can't be tabbed to but focus can be given to the element programmatically (using
- If given a value of 0, the element can be focused via the keyboard and falls into the tabbing flow of the document.
- Values greater than 0 create a priority level with 1 being the most important.