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 trialRicard Taujenis
4,383 Pointsplacing label tag
Have placed label tag were its supposed to be not working efficiently
<!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
David Abel
5,199 PointsTry placing your label before the select item
<label for="color">Shirt Color</label>
<select ID="color" name="shirt_color">
Michael Afanasiev
Courses Plus Student 15,596 PointsHey 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
David Abel
5,199 PointsMichael,
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
Courses Plus Student 15,596 PointsHey 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 example */
h1 {
display: block;
color: tomato;
}
a:visited, a:hover, a {
color: green;
}
Math.round();
document.write('Hello JavaScript');
:)
Ricard Taujenis
4,383 PointsIDk still dosnt work it asks for placing it inside of select menu :/
David Abel
5,199 PointsI 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
Courses Plus Student 15,596 PointsRicard, post your code again - perhaps we can spot the error.