【问题标题】:Radio button accessibility (508 compliance)单选按钮可访问性(508 合规性)
【发布时间】:2014-05-03 22:57:26
【问题描述】:

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

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

谢谢

【问题讨论】:

    标签: html accessibility section508


    【解决方案1】:

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

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

    【讨论】:

    • 这正是我所需要的。 :D
    • tabindex 呢?你肯定会被 ADA 盯上的
    【解决方案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>
    

    【讨论】:

      【解决方案3】:

      使用内容属性(如果可用)。

      【讨论】:

        猜你喜欢
        • 2019-01-27
        • 1970-01-01
        • 2012-07-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-18
        相关资源
        最近更新 更多