Skip to content
学习 衡量 博客 Case studies 关于
本页内容
  • Lighthouse 按钮名称审计失败的原因
  • 资源

按钮没有可访问的名称

May 2, 2019 — 更新日期 Mar 20, 2020
Available in: Español, 日本語, 한국어, Português, Русский, English
Appears in: 无障碍功能审核
本页内容
  • Lighthouse 按钮名称审计失败的原因
  • 资源

当按钮没有可访问的名称时,屏幕阅读器和其他辅助技术会将其声明为按钮 ,这样就不会向用户提供按钮功能的信息。

Lighthouse 按钮名称审计失败的原因 #

Lighthouse 会标记出缺少文本内容或 aria-label 属性的按钮:

Lighthouse 审计显示按钮没有可访问的名称
The Lighthouse Accessibility score is a weighted average of all the accessibility audits. See the Lighthouse accessibility scoring post for more information.

如何为按钮添加可访问的名称 #

对于带有可见标签的按钮,请将文本内容添加到 button 元素中。使标签成为明确的调用操作。例如:

<button>Book room</button>

对于没有可见标签的按钮,比如图标按钮,请使用 aria-label 属性向使用辅助技术的用户清楚地描述操作,例如:

此示例应用依赖 Google 的 Material icon font ,它使用连字将按钮的内部文本转换为图标字形。在宣布按钮时,辅助技术将引用 aria-label,而不是图标字形。

另请参阅标签按钮和链接。

资源 #

  • 按钮没有可访问的名称审计源代码
  • 按钮必须有可辨别的文字(德克大学)
Last updated: Mar 20, 2020 — Improve article
Return to all articles
分享
订阅

Contribute

  • 提交错误
  • 查看源代码

相关内容

  • developer.chrome.com
  • Chrome 动态
  • 网站开发基础
  • 案例研究
  • 播客
  • 节目

连接

  • Twitter
  • YouTube
  • Google Developers
  • Chrome
  • Firebase
  • Google Cloud Platform
  • 所有产品
  • 条款和隐私权
  • 社区准则

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies.