[英]how to prevent redundant text being read in screen reader?
This is my first time tackling accessibility.这是我第一次处理可访问性问题。 I am using talkback on my phone to test accessibility of items.
我在手机上使用对讲来测试项目的可访问性。 The issue I have is that if I have content in an anchor, it reads the entire thing once and then when you swipe it reads the individual text inside the anchor.
我遇到的问题是,如果我在锚点中有内容,它会读取整个内容一次,然后当您滑动它时,它会读取锚点内的单个文本。 Here's the code I have:
这是我的代码:
<ul>
<li class="relatedFeatured">
<a href="https://www.weather.com/" target="_blank" aria-labelledby="relatedLinks">
<div class="icon featuredIcon" aria-hidden="true"></div>
<div class="relatedFeaturedText" id="relatedLinks">
<strong>See the weather</strong>
<p>Visit and find information on the climate in your area.</p>
</div>
<span class="icon" aria-hidden="true"></span>
</a>
</li>
</ul>
I tried adding role=text like so,我尝试像这样添加 role=text ,
<ul>
<li class="relatedFeatured">
<a href="https://www.weather.com/" target="_blank" aria-labelledby="relatedLinks">
<div class="icon featuredIcon" aria-hidden="true"></div>
<div class="relatedFeaturedText" id="relatedLinks" role="text">
<strong>See the weather</strong>
<p>Visit and find information on the climate in your area.</p>
</div>
<span class="icon" aria-hidden="true"></span>
</a>
</li>
</ul>
However, it still reads the items individually inside.但是,它仍然会单独读取内部的项目。 The only other way I can think of is adding aria-hidden to that div, but not sure that is the proper way to go. Does anyone have any ideas as to what I need to correct?
我能想到的唯一其他方法是将 aria-hidden 添加到该 div,但不确定这是 go 的正确方法。有人对我需要更正的内容有任何想法吗?
I've tried the following using Chrome on a Samsung Galaxy S10 with TalkBack (Android 11):我在带有 TalkBack (Android 11) 的三星 Galaxy S10 上使用 Chrome 尝试了以下操作:
<ul>
<li class="relatedFeatured">
<a href="https://www.weather.com/" target="_blank">
<div class="icon featuredIcon" aria-hidden="true"></div>
<div class="relatedFeaturedText" id="relatedLinks">
<strong role="presentation">See the weather</strong>
<p role="presentation">Visit and find information on the climate in your area.</p>
</div>
<span class="icon" aria-hidden="true"></span>
</a>
</li>
</ul>
So, by using role="presentation"
on the <strong>
and <p>
tags, TalkBack only reads the text inside the <a>
tag, and not as individual text items.因此,通过在
<strong>
和<p>
标签上使用role="presentation"
,TalkBack 仅读取<a>
标签内的文本,而不是作为单独的文本项。 I also removed the aria-labelledby
attribute as it's redundant, given that the text inside the <a>
tag is already picke up by screen readers.我还删除了
aria-labelledby
属性,因为它是多余的,因为屏幕阅读器已经读取了<a>
标签内的文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.