I am New To Coding and Need some Help

I am asked to do the following: Add the name attribute with the value indoor-outdoor to both radio buttons.

However, when I write the code based on w3school suggestion, which is the following:

<input type="radio" name="indoor-outdoor" id="indoor">
<label for="indoor">Indoor</label>
<input type="radio" name="indoor-outdoor" id="outdoor">
<label for="outdoor">Outdoor</label>

It does not work. The following is the response I get: Sorry, your code does not pass. You’re getting there.

Both radio buttons should still be located between opening and closing label element tags.
What did I do incorrectly?

Thanks for your help
neophite

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

your inputs are not nested in the labels, they should be

I rewrote the code like the following: <label input type="radio" name="indoor-outdoor" value="indoor"> Indoor <input type="radio" name="indoor-outdoor" value="outdoor"> Outdoor </label>
However, I am still getting this response: Sorry, your code does not pass. You’re getting there.

Both radio buttons should still be located between opening and closing label element tags.

Where am I going wrong?

Thanks again for your help.

Hi! Here’s your code but in more readable way:

<label input type="radio"
             name="indoor-outdoor"
             value="indoor"> Indoor
<input type="radio"
       name="indoor-outdoor"
       value="outdoor"> Outdoor </label>

For example, valid variant:

<input type="radio"
       id="html"
       name="fav_language"
       value="HTML">
<label for="html">HTML</label>

<input type="radio"
       id="css"
       name="fav_language"
       value="CSS">
<label for="css">CSS</label>

And the nested version:

<label>CSS
  <input type="radio"
         name="fav_language"
         value="CSS">
</label>

Now I hope it’s clear where you need to fix
And to learn more about labels:

Thank you so much for your help, Ray13.

Here is a copy of the code I wrote, following your example:

  <input type="radio"
         name="indoor-outdoor"
         value="indoor"> Indoor
  <input type="radio"
         name="indoor-outdoor"
         value="outdoor"> Outdoor
</label>

When I checked the console, it worked, however, I am still getting this message when I clicked on Check the code: Sorry, your code does not pass. Don’t give up.

Both radio buttons should still be located between opening and closing label element tags.

You’re welcome, neophite.
In this snippet I see the only one closing label tag. Wrap both inputs in labels:

<label>Text
  <input>
</label>

Thanks again Ray13. I included the top label tag as well and got the same message, although the code works, based on what I saw in the console.

No problem, share your edited code, please

Here is myedited code: ```

Indoor

Outdoor

I don’t know why it did not paste, here it is again:

    <input type="radio"
         name="indoor-outdoor"
         value="indoor"> Indoor 

      <input type="radio"
         name="indoor-outdoor"
         value="outdoor"> Outdoor
</label>```

Funny, it’s not showing the top label tag. I’ll try again

<label>
    <input type="radio"
         name="indoor-outdoor"
         value="indoor"> Indoor 

      <input type="radio"
         name="indoor-outdoor"
         value="outdoor"> Outdoor
</label>

Is this the step you are doing?
Add the name attribute with the value indoor-outdoor to both radio buttons? Try resetting the lesson and only add name=“indoor-outdoor” to both inputs without changing the elements. I believe right now you are missing parts of the label elements.
This is how it looks at the beginning.
Indoor
Outdoor

I think I was blocked because they thought I was posting an answer. Start by resetting the lesson and only change the one part. Later they will teach the label element with for added. You are doing great. :slightly_smiling_face:

1 Like

Thanks a million, Katkesch1. It worked!

3 Likes

Your radio buttons are not enclosed within the label tags. wrap each input element with corresponding label element.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.