# 通过编写小测验学习无障碍 - 步骤 31

**URL:** <https://forum.freecodecamp.org/t/topic/565014>\
**Category:** General\
**Tags:** chinese-中文\
**Created:** [October 21, 2022, 3:34am UTC](https://forum.freecodecamp.org/t/topic/565014 "2022-10-21T03:34:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wjx915](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@wjx915](https://forum.freecodecamp.org/u/wjx915)\
**Post date:** [October 21, 2022, 3:34am UTC](https://forum.freecodecamp.org/t/topic/565014/1 "2022-10-21T03:34:35Z")

</div>

**告诉我们发生了什么：**

# 步骤 31

为 `label` 元素添加文本，使 `input` 在文本之前。 然后，给 `input` 元素一个与文本匹配的 `value`。

文本应为 `True` 或 `False`。

**你目前的代码**

```auto
<ul class="answers-list">
                <li>
                  <label for="q1-a1">
                    <input type="radio" id="q1-a1" value="ture" />aaa
                  </label>
                </li>
                <li>
                  <label for="q1-a2">
                    <input type="radio" id="q1-a2" value="ture" />ggg
                  </label>
                </li>
              </ul>
            </fieldset>
          </div>
          <div class="question-block">
            <p>2</p>
            <fieldset class="question" name="html-question-two">
              <legend>
                A label element nesting an input element is required to have a
                for attribute with the same value as the input's id
              </legend>
              <ul class="answers-list">
                <li>
                  <label for="q2-a1">
                    <input type="radio" id="q2-a1" value="ture" />sss
                  </label>
                </li>
                <li>
                  <label for="q2-a2">
                    <input type="radio" id="q2-a2" value="ture" />vvv
                  </label>
                </li>
              </ul>

```

警告

挑战的种子代码和/或你的解决方案超过了我们从挑战传送的最大长度。

你需要在此采取额外步骤，以确保你写的代码可以轻松地被阅读。

请复制/粘贴所有在挑战中编辑器所显示的代码。

````plaintext
用你的复制代码替换这两句。
请保留上方的 ``` 行和下方的 ``` 行
因为它们允许你的代码在帖子中被正确格式化。

````

**你的浏览器信息：**

用户代理是： `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.47`

**挑战：** 通过编写小测验学习无障碍 - 步骤 31

**挑战的链接：**

> **[freeCodeCamp.org](https://www.freecodecamp.org/chinese/learn/2022/responsive-web-design/learn-accessibility-by-building-a-quiz/step-31)**
>
> 免费学习编程

---

<div class="post-metadata">

**Author:** ![miya](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/miya/32/417705_2.png) [@miya](https://forum.freecodecamp.org/u/miya)\
**Post date:** [October 21, 2022, 8:31am UTC](https://forum.freecodecamp.org/t/topic/565014/2 "2022-10-21T08:31:48Z")

</div>

仔细理解题意哦，是要在 `<label></label>` 标签里添加文本 “True” 或者 “False”，同时在 `<input>` 标签里添加对应的 value，即 “true” 或者 “false”。

正确的代码是：

```auto
<ul class="answers-list">
                <li>
                  <label for="q1-a1">
                    <input type="radio" id="q1-a1" />
                  </label>
                </li>
                <li>
                  <label for="q1-a2">
                    <input type="radio" id="q1-a2" />
                  </label>
                </li>
              </ul>
            </fieldset>
          </div>
          <div class="question-block">
            <p>2</p>
            <fieldset class="question" name="html-question-two">
              <legend>
                A label element nesting an input element is required to have a
                for attribute with the same value as the input's id
              </legend>
              <ul class="answers-list">
                <li>
                  <label for="q2-a1">
                    <input type="radio" id="q2-a1" />
                  </label>
                </li>
                <li>
                  <label for="q2-a2">
                    <input type="radio" id="q2-a2" />
                  </label>
                </li>
              </ul>

```

另外，这里你是想写 true 吗？字母顺序写错了。

> [@wjx915](#):
>
> `value="ture"`

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 7, 2025, 3:42pm UTC](https://forum.freecodecamp.org/t/topic/565014/3 "2025-01-07T15:42:14Z")

</div>

Closed on January 7, 2025, 3:42pm UTC


