18910140161

HTML-如何防止在屏幕阅读器中读取冗余文本?-堆栈溢出

顺晟科技

2022-10-18 14:12:06

140

这是我第一次处理可访问性。我在手机上使用对讲来测试项目的可访问性。我的问题是,如果我在一个锚点中有内容,它会读取整个内容一次,然后当你滑动它时,它会读取锚点中的单个文本。下面是我的代码:

<代码><;UL>;<;Li类=";相关特色";>;<;a href=";https://www.weather.com/"目标=";_空白";Aria-labelledby=";相关链接";>;<;DIV类=";图标功能图标";aria-hidden=";正确";>;&;#57409<;/DIV>;<;DIV类=";RelatedFeaturedText";ID=";相关链接";>;<;strong>;查看天气<;/strong>;<;P>;访问并查找您所在地区的气候信息。<;/p>;<;/DIV>;<;span类=";图标";aria-hidden=";正确";>;&;#58124<;/span>;<;/a>;<;/Li>;<;/UL>;

我试着像这样添加role=text,

<代码><;UL>;<;Li类=";相关特色";>;<;a href=";https://www.weather.com/"目标=";_空白";Aria-labelledby=";相关链接";>;<;DIV类=";图标功能图标";aria-hidden=";正确";>;&;#57409<;/DIV>;<;DIV类=";RelatedFeaturedText";ID=";相关链接";角色=";文本";>;<;strong>;查看天气<;/strong>;<;P>;访问并查找您所在地区的气候信息。<;/p>;<;/DIV>;<;span类=";图标";aria-hidden=";正确";>;&;#58124<;/span>;<;/a>;<;/Li>;<;/UL>;

但是,它仍然可以单独读取内部的项目。我能想到的唯一其他方法是将Aria-Hidden添加到该DIV中,但不确定这是否是正确的方法。有人知道我需要纠正什么吗?


顺晟科技:

我在三星Galaxy S10(Android 11)上使用Chrome浏览器进行了以下尝试:

<代码><;UL>;<;Li类=";相关特色";>;<;a href=";https://www.weather.com/"目标=";_空白";>;<;DIV类=";图标功能图标";aria-hidden=";正确";>;&;#57409<;/DIV>;<;DIV类=";RelatedFeaturedText";ID=";相关链接";>;<;strong角色=";演示";>;查看天气<;/strong>;<;p角色=";演示";>;访问并查找您所在地区的气候信息。<;/p>;<;/DIV>;<;span类=";图标";aria-hidden=";正确";>;&;#58124<;/span>;<;/a>;<;/Li>;<;/UL>;

因此,通过使用<ul> <li class="relatedFeatured"> <a href="https://www.weather.com/" target="_blank" aria-labelledby="relatedLinks"> <div class="icon featuredIcon" aria-hidden="true">&#57409</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">&#58124</span> </a> </li> </ul> <ul> <li class="relatedFeatured"> <a href="https://www.weather.com/" target="_blank" aria-labelledby="relatedLinks"> <div class="icon featuredIcon" aria-hidden="true">&#57409</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">&#58124</span> </a> </li> </ul> <ul> <li class="relatedFeatured"> <a href="https://www.weather.com/" target="_blank"> <div class="icon featuredIcon" aria-hidden="true">&#57409</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">&#58124</span> </a> </li> </ul> 标签,Talkback只读取role="presentation"标记,而不是作为单独的文本项。我还删除了<strong>属性,因为它是多余的,因为<p>标记已被屏幕阅读器选取。

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航