我在 freecodecamp html。我收到一条错误消息,默认情况下应选中您表单上的第一个单选按钮

Im on freecodecamp html. and i am getting a error that says ,Your first radio button on your form should be checked by default

我一直在关注 HTML 的教程,它希望自动选中前两个复选框和两个单选按钮。但是每当我尝试使用我的代码时,您都可以在下面的第 20、21、22 和 23 行末尾看到。我似乎找不到解决办法。我试过重置代码并查看注释。我得到了除了正在检查的第一个单选按钮之外的所有内容。

    <h2>CatPhotoApp</h2>
    <main>
      <p>Click here to view more <a href="#">cat photos</a>.</p>
    
      <a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
    
      <p>Things cats love:</p>
      <ul>
        <li>cat nip</li>
        <li>laser pointers</li>
        <li>lasagna</li>
      </ul>
      <p>Top 3 things cats hate:</p>
      <ol>
        <li>flea treatment</li>
        <li>thunder</li>
        <li>other cats</li>
      </ol>
      <form action="https://www.freecatphotoapp.com/submit-cat-photo">
        <label for="indoor"><input id="indoor" type="radio" name="indoor-outdoor" value="indoor" checked>Indoor</label>
        <label for="outdoor"><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor" checked> Outdoor</label><br>
        <label for="loving"><input id="loving" type="checkbox" name="personality" value="loving" checked> Loving</label>
        <label for="lazy"><input id="lazy" type="checkbox" name="personality" value="lazy" checked> Lazy</label>
        <label for="energetic"><input id="energetic" type="checkbox" name="personality" value="energetic"> Energetic</label><br>
        <input type="text" placeholder="cat photo URL" required>
        <button type="submit">Submit</button>
      </form>
    </main>
```html

一组单选按钮只能同时被选中。您正在尝试在一组中选中两个单选按钮,要解决此问题,请确保只选中顶部的单选按钮,如下所示:

<label for="indoor"><input id="indoor" type="radio" name="indoor-outdoor" value="indoor" checked>Indoor</label>
<label for="outdoor"><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label>

我希望这有助于解决您的问题。

编辑:有关单选按钮的更多信息,请参阅 W3School:https://www.w3schools.com/tags/att_input_type_radio.asp