5

如果我想对“是/否”单选按钮提出问题。我如何需要标记代码,以便屏幕阅读器在选择单选按钮时阅读与“是/否”选择相关的问题,而不仅仅是阅读“是”和“否”标签?

<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>

谢谢

4

3 回答 3

10

对于这种性质的表单元素,我使用:

<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" 属性。这会将标签与所需的单选按钮相关联。

于 2010-06-10T18:01:15.923 回答
2
<fieldset>
<legend><span>Did you understand this? (choose one) </span></legend>
<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>
于 2010-06-10T17:57:22.347 回答
-1

使用 content 属性(如果可用)。

于 2010-06-10T17:58:54.197 回答