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 trial

HTML HTML Forms Choosing Options Create a Select Menu

Raeed Sabree
Raeed Sabree
10,664 Points

it says add a label element to the select menu with the text "shirt color" but its not working

what did i do wrong?

index.html
<!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
Mitchell Fargher
11,634 Points

You 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"

Raeed Sabree
Raeed Sabree
10,664 Points

okay just tried it but it didnt work

Raeed Sabree
Raeed Sabree
10,664 Points

okay just tried it but it didnt work

Mitchell Fargher
Mitchell Fargher
11,634 Points

You have the label inside the select tag. Move the label to above it just below the h1 tag.

Steven Parker
Steven Parker
231,248 Points

:point_right: You 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
Raeed Sabree
10,664 Points

okay so i took the <label outside of the select element but it didnt work

Steven Parker
Steven Parker
231,248 Points

You had gotten some bad advice previously about the for attribute - did you fix that?

Mitchell Fargher
Mitchell Fargher
11,634 Points

Whoops you're right. I put name instead of id.

Raeed Sabree
Raeed Sabree
10,664 Points

so instead of <label id="color">Shirt Color:</label> what do i put?

Steven Parker
Steven Parker
231,248 Points

The entire line would be:

    <label for="color">Shirt Color:</label>

I would put that right before the <select>.

Raeed Sabree
Raeed Sabree
10,664 Points

i put <label for="Shirt Color">Shirt Color:</label> but its not working

Raeed Sabree
Raeed Sabree
10,664 Points

i put <label for="Shirt Color">Shirt Color:</label> but its not working

Mitchell Fargher
Mitchell Fargher
11,634 Points

The for should be "color" not "Shirt Color" and make sure "color" is lowercase

Steven Parker
Steven Parker
231,248 Points

I did try to be as complete and correct as possible the first time. Hope it helped some.

Raeed Sabree
Raeed Sabree
10,664 Points

when i put that in right under the header it tells me to go back to task 1

Raeed Sabree
Raeed Sabree
10,664 Points

when i put that in right under the header it tells me to go back to task 1

Raeed Sabree
Raeed Sabree
10,664 Points

lmao i got it after 3 hours

Raeed Sabree
Raeed Sabree
10,664 Points

lmao i got it after 3 hours

Mitchell Fargher
Mitchell Fargher
11,634 Points

Hey 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!