form-labels
它能做什么
这项技能检查表单输入框是否有清晰且相连的标签。适用于构建许多人需要填写的表单的开发者。
适用场景
- ✓当表单字段只有占位文字,没有真正的标签的时候。
- ✓当一组复选框或单选按钮没有共同的问题说明的时候。
- ✓当用户无法点击标签来聚焦其输入框的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/form-labels/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我表单中的每个字段是否都有正确的标签。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会使用 for 和 id 属性验证每个输入框是否有相连的标签。它会用可见的标签替换只有占位文字的字段,并使用带有 legend 的 fieldset 包裹相关选项。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Associate labels with form controls
Properly associated labels ensure that screen readers can identify the purpose of form inputs and increase the clickable area for users with motor impairments.
Quick Reference
- Use
<label>elements for all form inputs - Connect labels using
forandidattributes - Placeholder text is not a label and must not be the only field name
- Use
<fieldset>and<legend>when multiple controls share one question - Ensure every input has a clear, accessible name
Check
Verify that all form controls (input, select, textarea) have programmatically associated labels using the 'for' and 'id' attributes. Flag placeholder-only labels and grouped controls that lack a fieldset legend.
Fix
Add a <label> element with a 'for' attribute that matches the 'id' of the corresponding input field. Replace placeholder-only labels with real label text and wrap related checkboxes or radio buttons in a <fieldset> with a <legend>.
Explain
Explain why associated labels are critical for screen reader users and how they improve the hit area for touch and mouse users.
Code Review
Review the rendered markup and interactive states that affect Associate labels with form controls. 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. Specifically check for placeholder-only labels and question groups that visually share a heading but lack a semantic <fieldset> and <legend>.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/accessibility/form-labels
常见问题
为什么占位文字不够?
占位文字会在用户开始输入时消失,这项技能指出它不能作为标签。
fieldset 有什么作用?
它将相关控件(例如单选按钮)归入一个共同的问题之下,这个问题称为 legend。
标签为什么对触屏用户有帮助?
相连的标签会增加可点击区域,这对有运动障碍的人有帮助。
详情
作者的原始描述
Use when reviewing rendered HTML, interactive components, or design-system patterns related to Associate labels with form controls. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
热度
- GitHub 星标
- 75k
- 排名
- #2858
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。