Web accessibility: tabindex

Introduction

According to WebAIM’s WCAG 2 Checklist

  • All page functionality is available using the keyboard, unless the functionality cannot be accomplished in any known way using a keyboard (e.g., free hand drawing).

tabindex = -1

  • Useful for off-screen content that appears on a specific event.
  • Not reachable via sequential keyboard navigation
  • But could be focused with JavaScript or visually by clicking with the mouse.

tabindex = 0

tabindex greater than 0

Which Elements Should Have Focus?

We should typically only add tabindex attributes to interactive elements, and not to our site content.

Reference

1個讚

需要的時候我也會設定哦
在 input 內容很多的時候很有方便~