Making Elements Focusable with Tabindex
Jonathan Snook tells us how to make arbitrary elements keyboard accessible using a clever aspect of the tabindex
attribute.
Entry Information
- Posted:
- Wed, 13th Dec 2006 at 14:12 UTC
- Filed under:
- Tags:
-
- no tags defined for this entry
Comments
skip to comment formBeware - the first part of the trick (value of -1) is invalid HTML.
From the HTML spec: "This value must be a number between 0 and 32767"
I would imagine this is why the element given a tabindex of -1 is not focusable; because it's an invalid value. Programmatic access wouldn't care if the value of the attribute was valid or not though, which would be why you can access it through JavaScript.
What happens if you leave the value blank? Would that emulate the action of a -1 value, or a zero? Would it even be valid code?