gpt4 book ai didi

html - 如何使用 ARIA HTML5 对屏幕阅读器和其他 AT 隐藏 ASCII 艺术?

转载 作者:搜寻专家 更新时间:2023-10-31 08:18:28 24 4
gpt4 key购买 nike

我们正在我们的网站上添加一些可爱的 ASCII 艺术。我们担心它可能会给屏幕阅读器带来问题,所以我考虑添加 aria-hidden="true"role="presentation" 这样屏幕阅读器就不会看不到 ASCII 艺术。这是正确的方法吗?我没有屏幕阅读器来测试,看起来 aria-hidden 或 role 没有完全隐藏内容。

看起来像这样:

ascii art

我可以将它作为图像来做,但如果将它作为实际文本来做会很酷,这是无法通过 CSS 选择的。无论如何,将角色作为图像来做对我来说感觉很奇怪。

最佳答案

正确使用的角色是 imgaria-labelaria-laelledby。这是来自 HTML Living Standard 的示例:

These features can be used to make accessibility tools render content to their users in more useful ways. For example, ASCII art, which is really an image, appears to be text, and in the absence of appropriate annotations would end up being rendered by screen readers as a very painful reading of lots of punctuation. Using the features described in this section, one can instead make the ATs skip the ASCII art and just read the caption:

<figure role="img" aria-labelledby="fish-caption"> 
<pre>
o .'`/
' / (
O .-'` ` `'-._ .')
_/ (o) '. .' /
) ))) >< <
`\ |_\ _.’ ‘. \
‘-._ _ .-’ ‘.)
jgs `\__\
</pre>
<figcaption id="fish-caption">
Joan G. Stark, “<cite>fish</cite>“.
October 1997. ASCII on electrons. 28×8.
</figcaption>
</figure>

关于html - 如何使用 ARIA HTML5 对屏幕阅读器和其他 AT 隐藏 ASCII 艺术?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22676072/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com