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 trialnicolaspeterson
8,569 PointsLabeling radio and checkboxes.
Hi guys, quick question. In the previous videos, Nick adds the labels for each radio and checkbox input immediately following the input element. My question is whether this is totally necessary, as the for attribute in the label explicitly links the input and the label.
1 Answer
Keith McGill
Full Stack JavaScript Techdegree Student 6,852 PointsIt is not totally necessary, but know that wherever you put the label is where the label will appear on the page. So, if you want to put the label in the front of the input element for example, the label would appear before the actual element.
Will show button input with label text "Small" to the right of the button:
<input type="radio" id="small" value="small" name="shirt_size"><label for="small">Small</label>
Will show label text "Small" to the left of the button input:
<label for="small">Small</label><input type="radio" id="small" value="small" name="shirt_size">