我刚刚开始了解 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/