How to allow only one radio button to be checked with HTML?

Spread the love

Sometimes, we want to allow only one radio button to be checked with HTML.

In this article, we’ll look at how to allow only one radio button to be checked with HTML.

How to allow only one radio button to be checked with HTML?

To allow only one radio button to be checked with HTML, we set the name attribute to the same name.

For instance, we write

<input type="radio" name="radAnswer" />

to set the name attribute of each radio button to radAnswer to only allow 1 radio button to be selected.

Conclusion

To allow only one radio button to be checked with HTML, we set the name attribute to the same name.

Leave a Reply

Your email address will not be published. Required fields are marked *