freeCodeCamp/guide/english/html/tutorials/basic-html/radio-button/index.md

23 lines
715 B
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Radio Button
---
# Radio Button
```html
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
```
Radio buttons can be used when you want to limit a user's selection to one option when multiple options are available. A user cannot choose 2 or more radio buttons in the same selection field. By giving a group of radio buttons the same name attribute, the selection of one button will automatically result in the deselection of other buttons.