HTML HTML Forms Choosing Options Radio Buttons

Even after adding the <br> and class="light", radio buttons are not appearing with their respective labels. Why?

          <label for="under_13">Under 13</label><input type="radio" id="under_13" value="under_13" name="user_age" class="light"><br>          
          <label for="above_13">Above 13</label><input type="radio" id="over_13" value="above_13" name="user_age" class="light">```

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 82,206 Points

Hi there.

The for attribute with label links with the name attribute. So to get the label and element to link together you'll need to use the same values in those attributes

<label for="under_13">Under 13</label><input type="radio" id="under_13" value="under_13" name="under_13" class="light"><br>          
          <label for="above_13">Above 13</label><input type="radio" id="over_13" value="above_13" name=under_13" class="light">

Actually, I could not get you Jonathan. What I understand is that the FOR attribute should be based on ID attribute. And, the NAME attribute should be same for all the checkboxes. For example, in one of the previous track, I had the following code and it worked.

<input type="checkbox" name="foods" value="Grapes">Grapes<br> <input type="checkbox" name="foods" value="Apples">Apples<br> <input type="checkbox" name="foods" value="Carrot">Carrot<br>