< Back to Guides | Learn more at PaulJAdam.com >

Tabindex - Accessibility Quick Guide

Tabindex attribute allows an element to be keyboard focusable when tabbing or via JavaScript .focus(). Only tabindex=-1 or 0 should be used, and only if native HTML controls can't be used.

Guidance

  1. Never use positive tabindex values, e.g. don't use tabindex=1, 2, 3, 4, etc..
  2. Rather than using <div tabindex="0">, use a native <button> or <a href> element which is already focusable.
  3. Use HTML5 autofocus attribute rather than tabindex if you need to start the user's focus in a different area than the top of the page.

Bad Example




Good Example

Show good example using autofocus