HTML attribute value - HTML | MDN
Skip to search

HTML attribute value
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
See full compatibility
Report feedback

elements of type
radio
are generally used in
radio groups
—collections of radio buttons describing a set of related options.
Only one radio button in a given group can be selected at the same time. Radio buttons are typically rendered as small circles, which are filled or highlighted when selected.
Try it


Select a maintenance drone:












p,
label {
font:
1rem "Fira Sans",
sans-serif;

input {
margin: 0.4rem;
They are called radio buttons because they look and operate in a similar manner to the push buttons on old-fashioned radios, such as the one shown below.
Note:
Checkboxes
are similar to radio buttons, but with an important distinction: radio buttons are designed for selecting one value out of a set, whereas checkboxes let you turn individual values on and off. Where multiple controls exist, radio buttons allow one to be selected out of them all, whereas checkboxes allow multiple values to be selected.
Value
The
value
attribute is a string containing the radio button's value. The value is never shown to the user by their
user agent
. Instead, it's used to identify which radio button in a group is selected.
Defining a radio group
A radio group is defined by giving each of radio buttons in the group the same
name
. Once a radio group is established, selecting any radio button in that group automatically deselects any currently-selected radio button in the same group.
You can have as many radio groups on a page as you like, as long as each has its own unique
name
For example, if your form needs to ask the user for their preferred contact method, you might create three radio buttons, each with the
name
property set to
contact
but one with the value
email
, one with the value
phone
, and one with the value
mail
. The user never sees the
value
or the
name
(unless you expressly add code to display it).
The resulting HTML looks like this:
html



Please select your preferred contact method:











Here you see the three radio buttons, each with the
name
set to
contact
and each with a unique
value
that uniquely identifies that individual radio button within the group. They each also have a unique
id
, which is used by the