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

matteo boni
matteo boni
5,087 Points

help me

Add a label element to the select menu with the text "Shirt Color:"

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">
        <option value="red">red</option>
        <option value="yellow">yellow</option>
        <option value="blue">blue</option>
        <option value="green">green</option>
        <option value="color">color</option>
      <label for="color">shirt color</label>
    </form>

  </body>
</html>

4 Answers

Michael Afanasiev
PLUS
Michael Afanasiev
Courses Plus Student 15,596 Points

Hey Matteo, your code is fine, just add the label TO the select menu, that means to place the label right above the <select> tag :)

matteo boni
matteo boni
5,087 Points

don't understand, it's possible write the code :) ? thanks

Michael Afanasiev
Michael Afanasiev
Courses Plus Student 15,596 Points

Sure.

Your code here:

index.html
     <select id="color" name="shirt_color">
        <option value="red">red</option>
        <option value="yellow">yellow</option>
        <option value="blue">blue</option>
        <option value="green">green</option>
        <option value="color">color</option>
      <label for="color">shirt color</label>

Should be:

index.html
      <label for="color">shirt color</label>   <------ Label should be here!
     <select id="color" name="shirt_color">
        <option value="red">red</option>
        <option value="yellow">yellow</option>
        <option value="blue">blue</option>
        <option value="green">green</option>
        <option value="color">color</option>
anil rahman
anil rahman
7,786 Points

<form action="index.html" method="post"> <h1>Shirt Order Form</h1> <label for="color">Shirt Color:</label> <!--Added code--> <select id="color" name="shirt_color"> <option value="red">red</option> <option value="yellow">yellow</option> <option value="blue">blue</option> <option value="green">green</option> <option value="color">color</option> </form>

anil rahman
anil rahman
7,786 Points

Just above the select tag so this line:

<select id="color" name="shirt_color">

To create a label you use <label></label> tags Then in the opening tag you use for attribute and link that to the id from the select tag to create a link to the label. Shirt Color is the text between the tags. <label for="color">Shirt Color:</label>

Also the following line might be preventing your from progressing

<option value="color">color</option>
LaToya Legemah
LaToya Legemah
12,600 Points

One more thing. Make sure you are closing your select statement. I don't see a </select> tag.