ARIA属性用于在HTML中读取替代文本(例如罗马数字) [英] ARIA attributes for reading alternative text (e.g. Roman Numerals) in HTML
问题描述
在我的HTML文档中,我使用罗马数字(例如:MMXV = 2015)。
In my HTML document I am using roman numbers (e.g.: MMXV = 2015).
是否有办法通知屏幕阅读器以其他方式解释某些文本(例如:罗马数字为二千一十五而不是MMXV)?
Is there a way to inform screen readers to interpret certain text in another way (e.g.: roman numerals as "Two thousand and fifteen" instead of M-M-X-V)?
我的猜测是会有一个ARIA属性,但我似乎找不到一个。例如:
My guess was that there would be an ARIA attribute, but I cannot seem to find one. E.g.:
<time datetime="2015" aria-?="Two thousand and fifteen">MMXV</time>
推荐答案
使用 aria-label 标签,为元素提供有意义的描述。
Use the aria-label tag to give the element a meaningful description.
然后,将屏幕上的罗马数字包装在 span
元素中,该元素具有 aria-hidden 属性设置为 true
从屏幕阅读器隐藏元素。
Then, hide the roman numerals from screen readers by wrapping them in a span
element that has the aria-hidden property set to true
to hide the element from screen readers.
<time datetime="2015" aria-label="Two thousand and fifteen">
<span aria-hidden="true">MMXV</span>
</time>
这篇关于ARIA属性用于在HTML中读取替代文本(例如罗马数字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!