Skip to content

Radio Buttons

Multiple choice questions

  • Lesson
  • 1 min read
  • 3 of 8 in this chapter

Radio Buttons

Radio buttons are used to create multiple choice questions where only one of multiple answer choices can be selected.

Each answer option has its own input and label elements. The value of the name attribute for all of the answer choices is the same to indicate they're all related to the same question.

Here's an example:

HTML
<br>
<p>Do you like pineapple on pizza?</p>
<input type="radio" id="y" name="pineapple-pizza" value="yes">
<label for="y">Yes</label><br>
<input type="radio" id="n" name="pineapple-pizza" value="no">
<label for="n">No</label><br>
<input type="radio" id="idk" name="pineapple-pizza" value="I don't know">
<label for="idk">I don't know</label>