Radio Buttons name attribute

The task is to Create a Set of Radio Buttons. I got everything right except one error message:
“Your radio buttons should be given the name attribute of indoor-outdoor.”

I can’t figure out what the problem is. The name attribute is set to indoor-outdoor or am I wrong?

My code for the Radio Buttons:

<label for="indoor">
<input type="radio"name=“indoor-outdoor”>indoor
</label>

<label for="outdoor">
  <input type="radio"name=“indoor-outdoor”>outdoor
</label>

It seems to be related to the quotation marks on the name attribute.

If you use the following characters, it works. But I honestly can’t explain this.

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

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

I also noticed that you forgot to assign an id to each of your radio buttons. This way the for attribute in the label would “go nowhere”.

It is considered best practice to set a for attribute on the label element, with a value that matches the value of the id attribute of the input element. This allows assistive technologies to create a linked relationship between the label and the related input element. For example:

Thank you! I just couldn’t get my head around it. I do not know tho why they were different this time. But thanks anyway!

Oh okay, I think understand. It worked for now without an assigned id but I will consider it in the future. Thank you!

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