How to add input element under the legend element to work with the checkbox field

Good Morning,

Can you please help with the following instructions I was given for an animal project to do the following:

Forms
Instruction:
Under the legend element, add an input with its type attribute set to checkbox and give it the option of: Loving

I’m not sure how to add this to the legend element…

<fieldset>
            <legend>Is your cat an indoor or outdoor cat?</legend>
            <label><input id="indoor" type="radio" name="indoor-outdoor" value="indoor"> Indoor</label>
            <label><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label>
          </fieldset>
          <fieldset>

Thanks much,
Loreanne

1 Like

Since this looks like homework, I’m not going to do it for you but.a checkbox is declared essentially the same way as a radio button, which you have above. Swap the terms and it should work for you.

1 Like

Thank you for your help! I have added checkbox to type but my code still does not run. Do you have any other hints?

Grately appreciated

1 Like

If I copy your code, then copy one of your lines and change the type to checkbox, it works just fine for me…

Please post your new code and perhaps we can see where it might be.

1 Like

Here is my example and still a problem.

<fieldset>
            <legend>Is your cat an indoor or outdoor cat?</legend>
            <label><input id="indoor" type="radio" name="indoor-outdoor" value="indoor"> Indoor</label>
            <label><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label>
            <label><input type="checkbox">Loving</label>
          </fieldset>
          <fieldset>
1 Like

If I copy/paste your code into a codepen, I see the checkbox. What were you expecting to see?

1 Like

I tested it with this code and it worked! And the one I sent earlier too!
<input type="checkbox"> Loving

Thank you so much
Have a GREAT Day!

Loranne

2 Likes