如果我想用“是/否”单选按钮提问。我需要如何标记代码,以便屏幕阅读器阅读与“是/否”选择相关的问题,而不是在选择单选按钮时只阅读"is"和“否”标签?
<span>Did you understand this? (choose one) </span>
<label>
<input type="radio" id="yes_no" name="yes_no" value="Yes" />
Yes
</label>
<label>
<input type="radio" id="yes_no" name="yes_no" value="No" />
No
</label>
谢谢
最佳答案
对于这种性质的表单元素,我使用:
<fieldset>
<legend>Did you understand the question?</legend>
<input type="radio" name="yes_no" id="yes">
<label for="yes">Yes</label>
<input type="radio" name="yes_no" id="no">
<label for="no">No</label>
</fieldset>
另请注意,页面上的所有 ID 值都应该是唯一的。如果您有一个需要共享描述符的元素,请将其添加为一个类。
我还使用 Fieldsets 为单选选择添加不同的边界。
并且一定要指定标签的 for="id_value"属性。这会将标签与所需的单选按钮相关联。
关于html - 单选按钮可访问性(符合 508),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3017003/