Lesson: HTML5 and CSS
Create a Set of Radio Buttons
You can use radio buttons
for questions where you want the user to only give you one answer.
Radio buttons are a type of input
Each of your radio buttons should be nested within its own label
element.
All related radio buttons should have the same name
attribute.
Here's an example of a radio button:
<label><input type="radio" name="indoor-outdoor"> Indoor</label>
Add a pair of radio buttons to your form. One should have the option of indoor
and the other should have the option of outdoor
.
The content on this page is licensed under Attribution-ShareAlike 4.0 International. Original authors: freeCodeCamp, the content was modified.