tabindex

自然顺序

链接一 → → 链接二

按 Tab 依次经过它们。

0 与 -1

tabindex=0:加入 Tab 顺序
tabindex=-1:只能脚本聚焦

-1 适合跳转目标、对话框、错误摘要。

不要用正数

<button tabindex="2">…</button>  

正数 tabindex 会让元素跳到自然顺序之前,难以维护。