[英]What is the correct way to make screen reader read span text
我是可访问性的新手,我有一个包含如下文本的跨度
<span class="text" >Account Information</span>
默认情况下,屏幕阅读器不会停在我的跨度上,也不会阅读它,所以我在 SO 上搜索和搜索,但没有一个解决方案有效
我最终得到了类似下面的结果,但仍然无法正常工作(我在 Chrome 上进行了测试,使用 JAWS 屏幕阅读器)
<span aria-live="assertive" class="text" role="region" tabindex="4" aria-label="Account Information">Account Information</span>
让屏幕阅读器阅读跨度文本的最佳做法是什么?
<section _ngcontent-lfb-c4="" class="toolbar">
<dx-button _ngcontent-lfb-c4="" class="maximizing-button dx-button dx-button-normal dx-button-mode-contained dx-widget dx-button-has-icon" ng-reflect-element-attr="[object Object]" ng-reflect-icon="material-icons mat-fullscreen" role="button" aria-label="Maximize Widget" tabindex="0" aria-pressed="false">
<div class="dx-button-content"><i class="dx-icon material-icons mat-fullscreen"></i></div>
</dx-button>
<span _ngcontent-lfb-c4="" aria-live="assertive" class="text" role="region" tabindex="4" aria-label="Account Information">
Account Information
</span>
<span _ngcontent-lfb-c4="" class="toolbar-right">
<span _ngcontent-lfb-c1="" class="total-account-value-info" role="note" tabindex="3" toolbar-right="">
(Total Account Value is as of the end of last business day)
</span>
</span>
</section>
我发现了我的错误,我正在分享以防其他人遇到同样的问题。
问题在于tabindex="4"
,实际上这会以某种方式改变选项卡的顺序。 所以我将其设置为0
并且我的问题已解决。
tabindex=0
当tabindex
设置为0
时,元素会根据其在源代码中的位置插入到 tab 顺序中。 如果默认情况下元素是可聚焦的,则根本不需要使用tabindex
,但是如果您要重新利用<span>
或<div>
之类的元素,则tabindex=0
是将其包含在 tab 顺序中的自然方式。
tabindex=-1
当tabindex
设置为负 integer (如-1
)时,它会以编程方式聚焦,但不包含在 tab 顺序中。 换句话说,使用 tab 键浏览内容的人无法访问它,但可以通过脚本专注于它。
tabindex>=1
当tabindex
设置为正 integer 时,事情就会出现问题。 它对与预期的 tab 顺序没有相似之处的内容强加了一个 tab 顺序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.