vendredi 18 mars 2022

Image selection input in html with checkbox or radio

I'm creating a web page and I want to create a section with images so the user can select only one by clicking on it. I'm trying with checkbox and radio but it only gets selected when I press on the checkbox itself, not in the image. How can I do that?

I've tried this:

<section>
        <fieldset>
                <legend><h2>Favorite character</h2></legend>
    
                <input type="checkbox" id="imagen">
                <label for="myCheckbox1"><img src="image.jpg"></label>
        </fieldset>
</section>

And also the same but with radio




Aucun commentaire:

Enregistrer un commentaire