html - 网页内容可访问性 - 名称

标签 html accessibility wcag2.0

我刚刚开始了解 Web 内容可访问性,我正在阅读 this document关于非文本内容

据此:

For non-text content that is a control or accepts user input, such as images used as submit buttons, image maps or complex animations, a name is provided to describe the purpose of the non-text content so that the person at least knows what the non-text content is and why it is there.

因此,我仔细检查了此处 name 的含义是否与 HTML name 属性相同,结果发现并非如此。

在文档底部附近,name 的定义如下:

姓名

text by which software can identify a component within Web content to the user

Note 1: The name may be hidden and only exposed by assistive technology, whereas a label is presented to all users. In many (but not all) cases, the label and the name are the same.

Note 2: This is unrelated to the name attribute in HTML.

所以我的问题是,如果这个名称不是 HTML 属性,我该如何将其合并到我的网站中?

最佳答案

这取决于您使用的控件。一些例子:

  • 输入控件、文本区域:

    label 元素与 for 属性结合使用,与该元素的 id 属性相匹配。

    <label for="input1">My label</label><input type="text" id="input1" />
    
  • 按钮

    如果您使用 button 元素,请在内容中包含说明

    <button>My label</button>
    

    对于input[type=submit],您可以使用value属性:

    <input type="submit" value="My label" />
    
  • 如果您想描述图像,请使用alt属性

    例如:

    <img src="..." alt="My label" />
    

关于html - 网页内容可访问性 - 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39836122/

相关文章:

ios - 让 VoiceOver 为 UIKeyInput 播报输入/删除的字符

pdf - 计算pdf中(Td,TD,Tm,cm,T*)内容流的确切位置?

javascript - 我如何使用 JavaScript 确定屏幕阅读器将读取的内容?

css - 当有超过 2 个 div 时,表格单元格拆分

javascript - (简单)HTML属性是否允许赋值之间有空格

javascript - 如何检测用户是否启用了 Mac OS 高对比度辅助功能设置?

accessibility - 促销折扣横幅的咏叹调角色

accessibility - WCAG 2.0 AA 级是否继承 A 级的要求?

html - "sidebar"似乎附加到 "main,"但我不确定如何/如何撤消

html - Css 顶部与其他元素对齐