跳到正文
Skillpedia
网站与界面(前端)75k · #2811

decorative-elements

它能做什么

这项技能检查页面上的装饰性图片和图标,并确保屏幕阅读器跳过它们。适合希望网站具有无障碍性的开发者。

适用场景

  • ✓当屏幕阅读器在你的页面上读出没有意义的图片名称时。
  • ✓当你添加装饰性分隔线、图标或背景图片时。
  • ✓当你在上线前审查页面的无障碍性时。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/decorative-elements/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/decorative-elements/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2811
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能