- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经四处搜索,如果可以将 aria-label
组合起来,我没有找到任何信息。和 aria-describedby
对于一个元素,它是否会导致使用屏幕阅读器的人感到困惑?
我有一个包含许多项目的列表,每个项目都有一个 title
然后在标题旁边是一个 PDF 图标,用于下载该项目的 pdf,如下所示:
<ul>
<li>
<div id="item-{{item.id}}">{{item.title}}</div>
<button class="icon-pdf"></button>
</li>
</ul>
我想知道我是否可以做这样的事情,它是否仍然对用户有意义,屏幕阅读器是否可以处理这种情况:
<ul>
<li>
<div id="item-{{item.id}}">{{item.title}}</div>
<button class="icon-pdf"
aria-label="Download PDF button"
aria-describedby="item-{{item.id}}">
</button>
</li>
</ul>
也许转换
button
会更好到一个链接,只需使用
title
这样的属性?
<a href="javascript:void(0);//Download PDF"
class="icon-pdf"
title="Download PDF"
aria-describedby="item-{{item.id}}">
</a>
最佳答案
简答
如果您使用超链接和在括号中添加文件类型和大小的推荐做法(哦,如果您的站点是多语言,则添加语言),则无需添加您尝试添加的额外信息。
长答案
要回答原始问题,是的,您可以使用 aria-label
和 aria-describedby
一起。它们用于不同的目的。aria-label
用于为控件提供可用名称,它 覆盖 任何语义派生的信息(即按钮文本)。aria-describedby
用于为自定义控件等提供附加信息。它还可以用于向屏幕阅读器用户提供提示。还有 this answer I gave has information about support for aria-describedby
等要考虑的事情。
如果你一起使用它们,你会得到 aria-label
先阅读再获取aria-describedby
信息阅读后。aria-label
的快速示例和 aria-describedby
一起
<button aria-label="read first" aria-describedby="extra-info">Not Read Out</button>
<div class="visually-hidden" id="extra-info">This would be read second</div>
在上面的例子中,它会读到“先读,这将是第二次读”,注意“未读出”原始按钮文本被完全覆盖。
title
属性,它不是一个很容易访问的属性,对大多数屏幕阅读器用户来说是无用的,因为它不会被宣布。 (对于任何仅使用键盘的用户等也无用。)body {
font-family: Century Gothic;
background: #272727;
}
.btn {
float: left;
width: 25%;
height: 30px;
padding: 1px 0px;
min-width: 200px;
margin: 2% .8%;
overflow: hidden;
background: #527EBF;
}
.btn:hover {
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
border-radius: 5px;
background: #666;
}
.btn a {
text-decoration: none;
}
.btn img {
width: 22px;
margin: 0 5px;
transition: all .5s ease;
position: relative;
left: 0;
transform: scale(0.7);
}
.btn .container span.text {
font-size: 12px;
color: #fff;
position: relative;
left: -3px;
top: -8px;
transition: all .45s ease-in-out;
}
.visually-hidden {
border: 0;
padding: 0;
margin: 0;
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 - a 0 height clip, off to the bottom right of the visible 1px box */
clip: rect(1px, 1px, 1px, 1px); /*maybe deprecated but we need to support legacy browsers */
clip-path: inset(50%); /*modern browsers, clip-path works inwards from each corner*/
white-space: nowrap; /* added line to stop words getting smushed together (as they go onto seperate lines and some screen readers do not understand line feeds as a space */
}
<div class="btn">
<a href="link-to-pdf.pdf"> <!--obviously if you want to intercept this with an event listener in JS then do so but leave the URL for fallback-->
<div class="container">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/PDF_file_icon.svg/267px-PDF_file_icon.svg.png" aria-hidden="true"/> <!-- hide the icon from screen readers with `aria-hidden`, preferably use a **inline** SVG instead of external image to save an uneeded request. -->
<span class="text">Item Name (PDF, 21MB)</span> <!-- added the file type and size as this is useful information for people, made it visible to all. If yourdesign won't allow for this then hide it as per second example -->
</div>
</a>
</div>
<div class="btn">
<a href="link-to-pdf.pdf">
<div class="container">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/PDF_file_icon.svg/267px-PDF_file_icon.svg.png" aria-hidden="true"/>
<span class="text">Item Name Hidden file size info <span class="visually-hidden">(PDF, 21MB)</span></span>
</div>
</a>
</div>
关于html - aria-label 和 aria-describedby 可以结合使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63694248/
我是 ARIA 角色的新手。如果我有工具提示类型功能,即如果有人单击问号按钮,会显示更多文本详细说明如何填写表单字段,我应该使用 aria-expanded 属性、aria-hidden 属性还是两者
我正在查看一些代码,其中一个标签具有属性 aria-owns 和 aria-expanded。我用谷歌搜索了它们,但没有找到足够的细节来完全理解它们的作用。 有人可以解释一下这些特定属性的用途吗?我对
当我通过 W3C 验证器运行它时,几天前使用无错误通过的 HTML 5 代码现在显示错误。错误看起来像这样: 元素 li 缺少以下一个或多个属性:aria-checked、aria-expanded、
有人可以详细说明aria-live="assertive"之间的区别吗?和 aria-live="polite" ? 据我了解 aria-live="assertive"将获得更高的优先级并清除队列,
我只是注意到,虽然 aria-label , aria-labelledby和 aria-describedby据说属性适用于每个元素(参见 https://www.w3.org/WAI/PF/ari
在我的网站上,用户可以单击“实时聊天”按钮,然后会出现一个聊天窗口。我正在寻找一些文本来读出(对于使用屏幕阅读器的辅助用户) 当聊天窗口出现时,焦点将转到输入文本框 - 用户可以在其中输入文本与顾问聊
W3C 将 WAI-ARIA 角色分为四组: 抽象角色 小部件角色 文档结构角色 标志性角色 有人可以解释一下抽象角色类别吗? 最佳答案 规范中确实提到: Abstract roles are the
W3C 将 WAI-ARIA 角色分为四组: 抽象角色 微件角色 文档结构角色 里程碑式的角色 有人可以解释抽象角色类别吗? 最佳答案 它确实在规范中说: Abstract roles are the
我试图让 voiceover 只读取 aria-describedby,但它是这样读取的(“我是一个按钮”未被读取) : 而如果有一个定义了 id aria-describedby="modal-la
人们问过 aria-controls 和 aria-owns 之间的区别。 aria-controls 是基于层次结构的父子关系,而 aria-owns 不是。 我想变得非常具体。 aria-cont
我已经四处搜索,如果可以将 aria-label 组合起来,我没有找到任何信息。和 aria-describedby对于一个元素,它是否会导致使用屏幕阅读器的人感到困惑? 我有一个包含许多项目的列表,
我有一个页面,我应该可以在没有太多更改的情况下访问该页面。 页面中的一个组合框被编码,以便在单击输入框时,div 的内容被复制到同一页面中的 iframe 元素中,并且该 iframe 在输入框下方可
使用时对元素的真正影响是什么 aria-owns="id" 和(!) aria-controls="id" 当使用这两个属性时,浏览器如何通知屏幕阅读器? 最佳答案 两个aria-controls和
使用 Bootstrap 模式,我经常看到这些 aria 属性,但我从来不知道如何使用它们。 有谁知道什么情况下使用这些属性?我用谷歌搜索——只是没有找到任何直接的答案。 最佳答案 HTML5 ARI
我想确定当用户单击其后代时可以自动隐藏一个元素(使用 JavaScript 来实现)。 例如: A Link 这是正确的方法吗? 最佳答案 虽然您可以创建自定义
使用 jQuery 在 #div1 中添加角色警报,读取 #div2 内容,即使它对于 JAWS 来说是隐藏的。 some content some con
我正在尝试将 aria-label 添加到网站上没有的所有链接。我想使用链接文本作为 aria-label。 $(document).ready(function () { $("a").each
我在互联网和 Angular Aria 文档上进行了搜索——它没有提到 aria-expanded 或 aria-selected? 有没有办法实现这个? 这将使: 谢谢。 最佳答案 我使用 ng
我发现了两种使用 aria- 属性标记区域的方法。 第一个: Blah-blah 第二个: Search results Blah-blah JAWS 读取它们完全相同。那
我有一个工具栏与各种按钮的列表。在某些情况下,按钮有一个标签,在其他情况下,它使用图像。。两者都被生成为具有到包含div的aria-Labelledby,该div具有标题属性。屏幕阅读器(NVDA,叙
我是一名优秀的程序员,十分优秀!