【问题标题】:Lighthouse error: "Buttons do not have an accessible name"Lighthouse 错误:“按钮没有可访问的名称”
【发布时间】:2019-05-10 17:36:05
【问题描述】:

如何解决这个 Lighthouse 错误:

按钮没有可访问的名称

<button class="search-button" type="submit" value="Search"></button>

我是初学者。

【问题讨论】:

  • 请分享一个相关按钮的标记示例。
  • :它给出了错误
  • 抱歉,我没有看到上面的评论是你的。我看看能不能帮忙。
  • 没问题,谢谢.... dequeuniversity.com/rules/axe/3.1/…

标签: html accessibility htmlbutton


【解决方案1】:

我会推荐此链接以供参考。

https://developers.google.com/web/tools/lighthouse/audits/button-name

它建议按钮应该有内部文本内容或 aria-label 或 aria-labelledBy。

<button class="search-button" type="submit">Search</button>

<button class="search-button" type="submit" aria-label="search"></button>

我展示了一个带有内部文本的按钮和一个带有 aria-label 的按钮。

【讨论】:

  • 是的,我知道。但我不知道编码:)
  • 当然,您能再提出一个问题并在此处链接吗?
  • "它建议按钮应该有内部文本内容,以及一个 aria-label 或 aria-labelledBy。"它只需要内部文本或 aria-label 而不是两者。
  • aria-label 属性应该可以工作
猜你喜欢
  • 2011-06-30
  • 2017-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多