decorative-elements
它能做什么
这项技能检查页面上的装饰性图片和图标,并确保屏幕阅读器跳过它们。适合希望网站具有无障碍性的开发者。
适用场景
- ✓当屏幕阅读器在你的页面上读出没有意义的图片名称时。
- ✓当你添加装饰性分隔线、图标或背景图片时。
- ✓当你在上线前审查页面的无障碍性时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/decorative-elements/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能确保我页面上的装饰性图标对屏幕阅读器隐藏吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查装饰性图片是否设置了空的 alt 值,并通过一个简单的属性隐藏装饰性图标。它也会避免把无害的装饰元素标记为问题。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Hide decorative elements from assistive technology
Screen readers announce every image and icon—decorative elements clutter the experience with meaningless 'image, decorative border, image, bullet' announcements.
Quick Reference
- Use alt='' (empty) for decorative images—not alt='image' or missing alt
- Add aria-hidden='true' to decorative SVGs and icons
- Use CSS background-image for purely decorative visuals
- Role='presentation' removes semantic meaning from elements
- Do not automatically raise performance findings on decorative micro-assets unless the snippet shows real layout instability
- Example safe pattern:
<img src="/divider.svg" alt="" aria-hidden="true">is usually a decorative no-op, not a finding by itself
Check
Verify decorative images have empty alt attributes (alt=''), decorative icons use aria-hidden='true', and background images used for decoration are not announced by screen readers. Do not report decorative images as accessibility or performance failures unless the code shows a concrete problem rather than a hypothetical optimization.
Fix
Add alt='' to decorative img elements. Add aria-hidden='true' to decorative SVGs and icon fonts. Use CSS background-image for purely decorative visuals instead of img elements.
Explain
Explain how screen readers announce every image and element unless explicitly hidden, and why decorative content clutters the experience for users navigating with assistive technology.
Code Review
Review the rendered markup and interactive states that affect Hide decorative elements from assistive technology. 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/decorative-elements
常见问题
什么是空的 alt 文本?
它是没有文字的 alt 属性,告诉屏幕阅读器跳过该图片。它适合纯装饰性的图片。
所有图标都应该隐藏吗?
只隐藏装饰性图标。这项技能针对的是装饰性元素,有意义的图片则需要文字描述。
小的装饰性图片会被报告为速度慢吗?
这项技能说明,除非代码显示真正的布局问题,否则不会这样报告。
详情
作者的原始描述
Use when reviewing rendered HTML, interactive components, or design-system patterns related to Hide decorative elements from assistive technology. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant. If an image is clearly decorative, default to no finding unless the snippet shows an actual issue such as broken semantics, focusability, or visible layout instability.
热度
- GitHub 星标
- 75k
- 排名
- #2811
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。