简体   繁体   English

如何防止在屏幕阅读器中阅读冗余文本?

[英]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">&#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>

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">&#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>

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">&#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>

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.

相关问题 如何限制屏幕阅读器不阅读某些文本? - How to restrict screen reader to not read a certain text? 如何在IE中使用屏幕阅读器阅读替代文本 - How to read alt text using a screen reader in IE 如何确定屏幕阅读器阅读文本的顺序? - How can I determine the order in which text is read by a screen reader? 防止屏幕阅读器聚焦“ aria-live”元素 - Prevent 'aria-live' element from being focused by screen reader 在阅读此 div 标签的文本时,如何防止屏幕阅读器说“组”? - How do I prevent the screen reader from saying "group" when reading this div tag's text? aria-label在不应该屏幕阅读时被阅读:WCAG - aria-label being read when it should not screen reader : WCAG 工具提示屏幕阅读器将读取的文字,但文字在视觉上保持隐藏 - Tooltip screen reader will read text of but text to remain visually hidden 如何以屏幕阅读器仍会阅读文本并向用户指示已禁用的方式“禁用”单选按钮? - How to “disable” a radio button in a way that a screen reader would still read the text and indicate to a user that it is disabled? 如何让屏幕阅读器宣布额外的文字 - How to let screen reader to announce extra text 如何隐藏文本并使屏幕阅读器可以访问它? - How to hide a text and make it accessible by screen reader?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM