Web 内容可访问性 - 名称

Web Content Accessibility - Name

我刚刚开始了解 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 的定义:

名字

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.

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

你说的"name"属性是你在网页中使用的标签的一个属性。示例:Tag Button 可以指定标签名称,方便用户使用。注 2 告诉您 HTML 标记与此属性无关。

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

  • 输入控件,文本区域:

    使用具有 for 属性的 label 元素,匹配元素的 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" />
    

上查看我的回答。另一个人在问一个对象的"name",我澄清说对象的名称不是name=属性(属性用于javascript)但是而是辅助技术将呈现给用户的对象的标签。更多细节在我的 post.