aria-input-field-name
它能做什么
这项技能检查文本框、多行文本框和下拉菜单是否有正确的标签。适合构建表单、并希望每个人都知道每个字段用途的开发者。
适用场景
- ✓当你用文本输入框、多行文本框或选择菜单构建表单时。
- ✓当某个字段只有占位文字,没有标签时。
- ✓当你在审查表单是否适合语音控制或屏幕阅读器使用时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-input-field-name/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的结账表单,确保每个字段都有正确关联的标签。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会查找通过 id 关联的 label 元素,或每个字段上的 aria-label、aria-labelledby,并标出仅依赖占位文字的字段。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Ensure all input fields have accessible names
Screen readers announce the accessible name of a focused input before the user types. Without a name, VoiceOver reads 'text field' and NVDA reads 'edit' with no context, making it impossible for blind users to fill out forms correctly. Voice control users (Dragon NaturallySpeaking) also need the visible label text to match the accessible name so they can say 'click Email Address' to move focus to the field.
Quick Reference
- Every
<input>,<textarea>, and<select>must have a programmatically associated accessible name - Preferred: associate a
<label>via matchingfor/idattributes - Alternatives:
aria-label(inline string) oraria-labelledby(references another element'sid) - Placeholder text is not an accessible name — it disappears on input and is not reliably announced
- Applies to WCAG 2.1 SC 1.3.1 (Info and Relationships) and SC 4.1.2 (Name, Role, Value)
Check
Find all <input> (excluding type='hidden'), <textarea>, and <select> elements. For each, check that one of these is true: (1) a <label> element with a for attribute matching the input's id exists, (2) the input has a non-empty aria-label attribute, or (3) the input has an aria-labelledby attribute pointing to a visible element. Flag any that use only placeholder as their label. Also check custom widgets using role=textbox, role=combobox, etc.
Fix
For each unlabeled input: (1) Add a <label for='input-id'>Label text</label> and matching id on the input — this is the most robust method. (2) If a visible label is impractical (e.g., search bar), add aria-label='Search' directly on the input. (3) If the label text already exists elsewhere in the DOM, add aria-labelledby='label-element-id' to the input. Remove placeholder as a substitute for a label; keep placeholder only as a hint for expected format.
Explain
WCAG 2.1 SC 4.1.2 (Name, Role, Value) requires that all user interface components have an accessible name. For form inputs, the accessible name is computed from: (1) aria-labelledby → (2) aria-label → (3) associated <label> → (4) title attribute (last resort). Screen readers announce this name when the input receives focus. Without it, a blind user hears only the input type ('text field') with no indication of what to type. Dragon NaturallySpeaking users need the accessible name to match visible text so voice commands work.
Code Review
Review the rendered markup and interactive states that affect Ensure all input fields have accessible names. 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/aria-input-field-name
常见问题
为什么占位文字不够?
这项技能说明,占位文字在用户输入时就会消失,而且不能被可靠地读出。
给字段添加标签的首选方式是什么?
使用 label 元素,并通过匹配的 for 和 id 属性相连。
语音控制用户也需要标签吗?
需要。这项技能指出,语音控制用户通过说出可见的标签文字来找到字段。
详情
作者的原始描述
Use when applies to all `<input>` (except type=hidden), `<textarea>`, `<select>`, and custom form widgets using role=textbox, role=combobox, role=spinbutton, role=searchbox, or role=listbox.
热度
- GitHub 星标
- 75k
- 排名
- #2729
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。