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

Ricard Taujenis
Ricard Taujenis
4,383 Points

placing label tag

Have placed label tag were its supposed to be not working efficiently

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= 'color'>

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

    </form>

  </body>
</html>

3 Answers

Try placing your label before the select item

<label for="color">Shirt Color</label> <select ID="color" name="shirt_color">

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

Hey Ricard,

The Label tag should be placed right above the selection tag like so:

 <form action="index.html" method="post">
      <h1>Shirt Order Form</h1>
      <label>Shirt Color</label> <-------- Label tag should be here 
        <select ID="color" name="shirt_color">

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

Check out the MDN documentation about Labels here.

Hope this helps! :D

Michael,

How do you format the code to get what you displayed above. I'm kind of new to posting to board here and I couldn't see how to format my answer this way. Thanks.

Okay, I think I see it now. I used the tick marks, but I also need to specify the language I'm writing in. Thanks!

Michael Afanasiev
Michael Afanasiev
Courses Plus Student 15,596 Points

Hey David, you can use the Markdown Cheatsheet (at the bottom of every comment/answer you make) to see syntax examples for formatting. But basically you use it like this:

```html (or CSS, JavaScript or any language)
your code here will be formatted by the language to specify.
end your code with a another ```

For example:

CSS.css
/* CSS example */

h1 {
     display: block;
     color: tomato;
}

a:visited, a:hover, a {
    color: green;
}
JavaScript.js
Math.round();
document.write('Hello JavaScript');

:)

Ricard Taujenis
Ricard Taujenis
4,383 Points

IDk still dosnt work it asks for placing it inside of select menu :/

I was able to make it work as both Michael and I describe above. Place the label on the line above the select element. Be sure to use the closing tag. It should work.

Michael Afanasiev
Michael Afanasiev
Courses Plus Student 15,596 Points

Ricard, post your code again - perhaps we can spot the error.