I need help, how I create set of Radio Buttons

Tell us what’s happening:
Describe your issue in detail here.
Hi everyone
I have a doubt, which of these variations are correct?
I try these different ways and I get the same result
The code
First

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

Second

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

Third

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

Link to the challenge:

What do you mean you get the same result?
Only the third one would even get a shot at being correct as the others are not using the “label”-tag correctly (among a couple of other issues).

So at best the third might pass the tests. Which begs the question, what “same results”?

1 Like

I refer to I get the same results visually.
I don’t know if the back execution is different between them.
For that reason, I ask which is correct or how I can write the correct code for this case

Hi @lennin_2021 !

Welcome to the forum!

With HTML, you have to be careful because the results might visually appear on the screen but your code is technically incorrect.

HTML sometimes will still display the content even if your code is not correct.

For example, if I were to write something like this

  <p>Things cats love:</>

Then it would still display the text
Screen Shot 2021-11-29 at 5.29.55 AM

Don’t be fooled if it still displays on the screen. :grinning:

Hope that helps!

2 Likes

The one that passes the challenge is correct :wink:

If you got more specific questions, we are happy to help. But you got the editor AND some tests there, which will tell you what is right and what isn’t. Asking us is kinda pointless.

As for the “looks the same” part - that’s not the point of the task.
Please read again what label does and why it’s being used. Also you can just try clicking on the inputs, to see the difference.

2 Likes

It should also be noted that in “second” the value for the id attribute is the same.
An id must be unique within the document.

3 Likes

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