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 trialRaeed Sabree
10,664 Pointsit says add a label element to the select menu with the text "shirt color" but its not working
what did i do wrong?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML Forms</title>
</head>
<body>
<form action="index.html" method="post">
<h1>Shirt Order Form</h1>
<select id="color" name="shirt_color">
<label id="color">Shirt Color:</label>
<option value="red">Red</option>
<option value="yellow">Yellow</option>
<option value="purple">Purple</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
<option value="orange">Orange</option>
</select>
</form>
</body>
</html>
3 Answers
Mitchell Fargher
11,634 PointsYou need to add a "for tag" on the label.
<label for="color">
This will let the label know it is for the select id="color"
Steven Parker
231,269 PointsYou have a few issues:
- you have two elements with the id "color". Every id in the document must be unique.
- the
<label>
element must be outside the<select>
. Only<option>
elements should be inside a<select>
. - the label element should be associated with the select using the for attribute set to the value "color"
- remember that for attributes associate with id not name (so "color", not "shirt_color")
- for this challenge, the label element does not need an id attribute.
I'm betting you can get it now without an explicit spoiler.
Raeed Sabree
10,664 Pointsokay so i took the <label outside of the select element but it didnt work
Steven Parker
231,269 PointsYou had gotten some bad advice previously about the for attribute - did you fix that?
Mitchell Fargher
11,634 PointsWhoops you're right. I put name instead of id.
Raeed Sabree
10,664 Pointsso instead of <label id="color">Shirt Color:</label> what do i put?
Steven Parker
231,269 PointsThe entire line would be:
<label for="color">Shirt Color:</label>
I would put that right before the <select>
.
Raeed Sabree
10,664 Pointsi put <label for="Shirt Color">Shirt Color:</label> but its not working
Raeed Sabree
10,664 Pointsi put <label for="Shirt Color">Shirt Color:</label> but its not working
Mitchell Fargher
11,634 PointsThe for should be "color" not "Shirt Color" and make sure "color" is lowercase
Steven Parker
231,269 PointsI did try to be as complete and correct as possible the first time. Hope it helped some.
Mitchell Fargher
11,634 Points<label for="color">
Raeed Sabree
10,664 Pointswhen i put that in right under the header it tells me to go back to task 1
Raeed Sabree
10,664 Pointswhen i put that in right under the header it tells me to go back to task 1
Raeed Sabree
10,664 Pointslmao i got it after 3 hours
Raeed Sabree
10,664 Pointslmao i got it after 3 hours
Mitchell Fargher
11,634 PointsHey you still got it! Just make sure you understand why it had to be written this way and you can chalk it up as a win!
Raeed Sabree
10,664 PointsRaeed Sabree
10,664 Pointsokay just tried it but it didnt work
Raeed Sabree
10,664 PointsRaeed Sabree
10,664 Pointsokay just tried it but it didnt work
Mitchell Fargher
11,634 PointsMitchell Fargher
11,634 PointsYou have the label inside the select tag. Move the label to above it just below the h1 tag.