我'm trying to improve my website by making it more accessible and compliant with WCAG 2.0 (Level AA) guidelines. It'是一个使用Contact Form 7创建表单的Wordpress站点 . 默认情况下,Contact Form 7不会将 label
添加到其 input
元素中 . 将 label
完整的 for
属性手动添加到类型为"text"的 input
是很容易的:
<label for="address">Street Address*</label>
[text* Address1 id:address]
但是,在生成带有Contact Form 7的单选按钮标记时,'m having trouble doing this for radio buttons. I know that there'是"use_label_element"的一个选项,但是这只会生成一个空 label
标记 - 它不包含 for
属性 . 在这里_2519912已尝试:
[radio RelativesWork use_label_element "Yes" "No"]
该短代码生成以下HTML . 请注意,我使用短代码添加的ID放在包装器 span
上,并且每个 label
都不包含 for
属性 .
<span class="wpcf7-form-control-wrap RelativesWork">
<span class="wpcf7-form-control wpcf7-radio" id="relatives">
<span class="wpcf7-list-item first">
<label>
<input type="radio" name="RelativesWork" value="Yes" />
<span class="wpcf7-list-item-label">Yes</span>
</label>
</span>
<span class="wpcf7-list-item last">
<label>
<input type="radio" name="RelativesWork" value="No" />
<span class="wpcf7-list-item-label">No</span>
</label>
</span>
</span>
</span>
我了解到有一个名为“Contact Form 7:Accessible Defaults”的补充插件,所以我安装并尝试了 . 但是,据我所知,这根本不涉及单选按钮 .
任何人都可以帮我弄清楚如何将 label
包含 for
属性添加到我使用Contact Form 7创建的每个单选按钮 .
谢谢!
爵