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

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

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"

okay just tried it but it didnt work

okay just tried it but it didnt work

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

Steven Parker
Steven Parker
241,434 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.

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

Steven Parker
Steven Parker
241,434 Points

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

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

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

Steven Parker
Steven Parker
241,434 Points

The entire line would be:

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

I would put that right before the <select>.

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

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

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

Steven Parker
Steven Parker
241,434 Points

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

<label for="color">

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

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

lmao i got it after 3 hours

lmao i got it after 3 hours

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!