Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialrk15
1,963 PointsEven 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
Treehouse Moderator 91,253 PointsHi 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">
rk15
1,963 Pointsrk15
1,963 PointsActually, 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>