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

Jacob Arias
Jacob Arias
4,353 Points

Need help with a challenge

The challenge: Add a label above the radio button group that says "Shirt Size:". Don't associate it with any specific element.

<form action="index.html" method="post">
      <h1>Shirt Order Form</h1>
      <label for="color">Shirt Color:</label>
      <select id="color" name="shirt_color">
         <label>Shirt Size:</label>
        <input type="radio" id="small" value="small" name="shirt_size">
        <input type="radio" id="medium" value="medium" name="shirt_size">
        <input type="radio" id="large" value="large" name="shirt_size">
Jacob Arias
Jacob Arias
4,353 Points

sorry, incorrect snapshot of the code. See later posting for correct code. Thanks.

14 Answers

Jose Luis Lopez
Jose Luis Lopez
19,179 Points

<!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> <label for="color">Shirt Color:</label> <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>

  <label>Shirt Size:</label>
  <input type="radio" id="small" value="small" name="shirt_size">
  <input type="radio" id="medium" value="medium" name="shirt_size">
  <input type="radio" id="large" value="large" name="shirt_size">

  <button type="submit">Place Order</button>
</form>

</body> </html>

Think I have got it:

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

    <label>Shirt Size:</label>
    <input type="radio" id="small" value="small" name="shirt_size">
    <input type="radio" id="medium" value="medium" name="shirt_size">
    <input type="radio" id="large" value="large" name="shirt_size">
   <label for="color">Shirt Color:</label>
  <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>

  <button type="submit">Place Order</button>
</form>

</body> </html>

I guess what you are doing is <label for="Shirt Size"></label> by doing that you are associating the element to another element. Look the code below.

<label>Shirt Size</label>
        <input type="radio" id="small" value="small" name="shirt_size">
        <input type="radio" id="medium" value="medium" name="shirt_size">
        <input type="radio" id="large" value="large" name="shirt_size">
Jacob Arias
Jacob Arias
4,353 Points

Marcelo, That is exactly what I had but it would not accept it. It prompted me to add a label element in the <form> section and above the first radio button. Which is what I thought I was doing. Not sure what the problem is with it.

Josip Ivković
PLUS
Josip Ivković
Courses Plus Student 1,455 Points

Finally figured it out, you need to put it like this:

select .... /select

label...

And then add the radio buttons and the label after the whole select section. Please fix it so that you can-t pass the first 2 tasks and then get stuck on the 3rd one because of this. Also, you could choose your wording a bit better here...

Jacob,

Remember, the <label> element in the code goes after the radio button (but will appear before).

Jacob Arias
Jacob Arias
4,353 Points

James, I tried that but that didn't work.

Show me your code. I just did it on the challenge and works properly.

Jacob Arias
Jacob Arias
4,353 Points

<label for="color">Shirt Color:</label> <select id="color" name="shirt_color"> <label>Shirt Size:</label> <input type="radio" id="small" value="small" name="shirt_size"> <input type="radio" id="medium" value="medium" name="shirt_size"> <input type="radio" id="large" value="large" name="shirt_size">

Jacob Arias
Jacob Arias
4,353 Points

I don't know why but every time I copy and paste my code for the forum it shows up in my dialogue box but doesn't show up on my forum post. My code was exactly as you had yours written out.

Jacob Arias
Jacob Arias
4,353 Points

I don't know why but every time I copy and paste my code for the forum it shows up in my dialogue box but doesn't show up on my forum post. My code was exactly as you had yours written out.

Below the field to post a comments says "Markdown Cheatsheet" hit on it, there is the way to put your code properly.

Jacob Arias
Jacob Arias
4,353 Points

Here you go. Thanks for that.

<label for="color">Shirt Color:</label>
      <select id="color" name="shirt_color">
        <label>Shirt Size:</label>
        <input type="radio" id="small" value="small" name="shirt_size">
        <input type="radio" id="medium" value="medium" name="shirt_size">
        <input type="radio" id="large" value="large" name="shirt_size">

It is the right one, is still giving you any problem?

Change the browser...

Jacob Arias
Jacob Arias
4,353 Points

I tried another browser. It still didn't take. I got a prompt that said "you need to add a label element within the form element, right before the first radio button.

Here is the code I entered again:

<form action="index.html" method="post">
      <h1>Shirt Order Form</h1>
      <label for="color">Shirt Color:</label>
      <select id="color" name="shirt_color">
        <label>Shirt Size:</label>
        <input type="radio" id="small" value="small" name="shirt_size">
        <input type="radio" id="medium" value="medium" name="shirt_size">
        <input type="radio" id="large" value="large" name="shirt_size">
        <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>
Jacob Arias
Jacob Arias
4,353 Points

I got it. Another user posted a comment telling me to put my radio button below the select menu. That worked. Thank you very much for your help.

tamirg
tamirg
6,201 Points

Task 3 will not work. I checked the forums and It seems that I am doing it correctly?? I am confused and tried it several different ways? Any other suggestions?

Anika Jaffara
Anika Jaffara
20,364 Points

Me too. Seems it needs some adjusting. I believe it asks a questions that hasn't been covered yet.

im experiencing the same problem, help

DUDE, I almost finished the Quiz, browser went out, restart now #3 it says BUMMER? You need Shirt Size with new label element. Worked the first Round!

<form action="index.html" method="post"> <h1>Shirt Order Form</h1> <label for="color">Shirt Color:</label> <select id="color" name="shirt_color"> <label>Shirt Size:</label><-- What could I be DOING wrong, I had this in my Notes when it passed the first time! <input type="radio" id="small" value="small" name="shirt_size"> <input type="radio" id="medium" value="medium" name="shirt_size"> <input type="radio" id="large" value="large" name="shirt_size"> <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>

NEVER MIND looked above one more time and I put the Radio buttons and label AFTER the /select. FORUMS ARE SPECTACULAR TIME SAVORS, SO MUCH HOMEWORK, SHOOT ME

Ashenafi Ashebo
Ashenafi Ashebo
15,021 Points

Put the radio Element outside of the select Element, Look the following code what I did to fix this problem

<!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> <label for="color">Shirt Color:</label> <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>

  <label>Shirt Size</label>
    <input type="radio" id="small" value="small" name="shirt_size">
    <input type="radio" id="medium" value="medium" name="shirt_size">
    <input type="radio" id="large" value="large" name="shirt_size">

  <button type="submit">Place Order</button>
</form>

</body> </html>

Viv Fouracre
Viv Fouracre
9,062 Points

Put the radio Element outside of the select Element as it definitely does not work inside the select element even though the 2 tasks before where you are creating the radio buttons pass as correct.

</select>

  <label>Shirt Size:</label>
    <input type="radio" id="small" value="small" name="shirt_size">
    <input type="radio" id="medium" value="medium" name="shirt_size">
    <input type="radio" id="large" value="large" name="shirt_size">

  <button type="submit">Place Order</button>
</form>
<form action="index.html" method="post">
      <h1>Shirt Order Form</h1>
      <label for="color">Shirt Color:</label>
      <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>
        <label>Shirt Size:</label>
        <input type="radio" id="small" value="small" name="shirt_size">
        <input type="radio" id="medium" value="medium" name="shirt_size">
        <input type="radio" id="large" value="large" name="shirt_size">
    </form>