简体   繁体   English

辅助功能:aria-hidden="true"(屏幕阅读器隐藏)和可聚焦元素(允许键盘访问)

[英]Accessibility: aria-hidden="true" (hide for screen readers) with focusable elements (allow keyboard access)

I want to hide this theme-switcher div from screen readers, as they are needed to change the theme colours.我想对屏幕阅读器隐藏这个主题切换器 div,因为需要它们来更改主题颜色。 But it should be focusable for keyboard users.但对于键盘用户来说,它应该是可聚焦的。

My problem is, it is not allowed to have focusable elements inside an aria-hidden node.我的问题是,不允许在 aria-hidden 节点中包含可聚焦元素。

Is there a workaround or best practice for this kind of problems?是否有针对此类问题的解决方法或最佳实践?

<div id="theme-switcher" aria-hidden="true">
  <button>Light</button>
  <button>Dark</button>
</div>

In fact, you shouldn't hide the color switcher to scren readers.事实上,您不应该向屏幕阅读器隐藏颜色切换器。 That's quite a bad idea, because ascreen reader user isn't necessarily completely blind.这是一个非常糟糕的主意,因为屏幕阅读器用户不一定完全失明。

You may have enough vision to see colors and have an use for the color switcher, but need a screen reader because you don't have enough vision to read text even with a zoom.您可能有足够的视力来查看 colors 并使用颜色切换器,但需要屏幕阅读器,因为即使使用缩放您也没有足够的视力来阅读文本。

So, you'd better leave the color switcher as it is without hidding it to screen readers.因此,您最好让颜色切换器保持原样,不要向屏幕阅读器隐藏它。

I think I found the solution.我想我找到了解决方案。

By implementing a "skip to content" Link, this and any other blocks can be skipped.通过实现“跳到内容”链接,可以跳过此块和任何其他块。 So there is no need, to add any aria-hidden tag here.所以没有必要在这里添加任何 aria-hidden 标签。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “[aria-hidden=”true“] 元素包含可聚焦的后代”; 解决这个问题的最佳方法? - “[aria-hidden=”true“] elements contain focusable descendents”; best way to fix that? 屏幕阅读器是否可以读取具有 aria-hidden 和 css visible:hidden 属性的元素? - Does an elements with the attribute aria-hidden and css visibility:hidden get read by screen readers? 显示模式时的“aria-hidden 元素不包含可聚焦元素”问题 - “aria-hidden elements do not contain focusable elements” issue when modal is shown 链接中的图标可访问性(隐藏) - Icon accessibility within links (aria-hidden) 可访问性:`tabindex=&quot;-1&quot;` 是否意味着该元素对屏幕阅读器不可见(类似于 `aria-hidden=&quot;true&quot;`) - Accessibility: does `tabindex="-1"` mean the element is not visible to screenreaders (similar to `aria-hidden="true"`) 为所有图像添加aria隐藏的true - Adding aria-hidden true for all images aria-hidden = true应用程序内部 - aria-hidden=true inside application 使用 aria-hidden=&quot;true&quot; 隐藏 Flash 元素和 iFrame 是否有助于使我的网站易于访问? - Does hiding flash elements & iFrames with aria-hidden="true" help make my website accessible? 父母的Aria-hidden = true不会让其子女也被Aria-hiden - Aria-hidden=true on parent does not make its children also aria-hidden bootstrap模态关闭按钮aria-hidden = true - bootstrap modal close button aria-hidden=true
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM