focus-order
它能做什么
这项技能检查键盘焦点在页面中移动的顺序。适用于希望键盘用户能顺畅浏览内容的开发者。
适用场景
- ✓当按 Tab 键时,焦点以令人困惑的方式在页面中跳动的时候。
- ✓当页面使用了你想要移除的正值 tabindex 的时候。
- ✓当对话框关闭后焦点没有回到正确位置的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/focus-order/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我页面的 Tab 顺序是否合理。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查 HTML 的顺序以及所使用的任何 tabindex 值。它会建议调整标记,使其与视觉布局一致,并避免使用正值的 tabindex 数字。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Ensure logical focus order
When focus jumps unexpectedly, keyboard users get disoriented and can't find content—mismatched visual and focus order makes navigation impossible.
Quick Reference
- Tab order should match visual reading order (left-to-right, top-to-bottom)
- DOM order determines tab order—arrange HTML to match visual layout
- Never use positive tabindex values (1, 2, 3)—they break natural flow
- Use CSS for visual positioning, not DOM reordering
Check
Tab through the page and verify focus moves in a logical sequence matching visual layout. Check that modals trap focus appropriately, and focus returns to triggering elements when dialogs close.
Fix
Order DOM elements to match visual layout. Avoid positive tabindex values which override natural order. Use tabindex='0' for custom interactive elements and tabindex='-1' for programmatic focus management.
Explain
Explain how keyboard users rely on predictable tab order to navigate efficiently, and why mismatched visual and focus order creates confusion and reduces usability for assistive technology users.
Code Review
Review the rendered markup and interactive states that affect Ensure logical focus order. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/accessibility/focus-order
常见问题
Tab 顺序为什么重要?
键盘用户依赖可预测的顺序来高效地浏览页面。
我应该用 CSS 移动元素吗?
这项技能推荐使用 CSS 进行视觉定位,而不是重新排列 HTML。
tabindex 0 和 -1 是什么意思?
这项技能说明,0 会使自定义元素加入 Tab 顺序,而 -1 只允许由代码获得焦点。
详情
作者的原始描述
Use when reviewing rendered HTML, interactive components, or design-system patterns related to Ensure logical focus order. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
热度
- GitHub 星标
- 75k
- 排名
- #2851
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。