You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

aria-label与aria-labelledby的行为差异及实际使用问题

带Label的下拉按钮无法被屏幕阅读器识别aria-labelledby关联标题

我有一个包含多个下拉列表按钮的工具栏,部分按钮使用<label>显示文本,部分使用<img>显示图标。两类按钮均通过aria-labelledby关联带有title属性的外层div。测试发现,NVDA、Narrator等屏幕阅读器在图片按钮场景下能正常识别aria-labelledby,但在label按钮场景下无法识别。切换为aria-label可解决该问题,但由于初始构建内容时标题文本未知,此方案存在局限性。

Label按钮问题代码示例

<button name="dd-selected-button" type="button" class="dd-selected" aria-haspopup="listbox" aria-expanded="false" aria-controls="dd-options-ID_1694283703078" aria-labelledby="fontSizeDropDown">
  <label class="dd-selected-text">10</label>
</button>

图片按钮正常代码示例

<button name="dd-selected-button" type="button" class="dd-selected" aria-haspopup="listbox" aria-expanded="false" aria-controls="dd-options-ID_1694283703042" aria-labelledby="fontDropDown">
   <img class="dd-selected-image" src="../images/fonts/arial.png">
</button>

内容的提问来源于stack exchange,提问作者Alain P

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 04:42:13