HTML

HTML <input

type=”radio”>

❮ HTML <input> type attribute

Example

Radio buttons let a user select only one of a limited number of choices:

<input type=”radio” id=”html” name=”fav_language” value=”HTML”>
<label
for=”html”>HTML</label><br>
<input type=”radio” id=”css” name=”fav_language”
value=”CSS”>
<label for=”css”>CSS</label><br>
<input type=”radio” id=”javascript”
name=”fav_language” value=”JavaScript”>
<label for=”javascript”>JavaScript</label>

Try it Yourself »

Definition and Usage

The <input type="radio"> defines a radio button.

Radio buttons are normally presented in radio groups (a collection of radio buttons
describing a set of related options). Only one radio button in a group can
be selected at the same time.

Note: The radio group must have share the same name (the
value of the name attribute) to be treated as a group. Once the radio group is
created, selecting any radio button in that group automatically deselects any
other selected radio button in the same group. You can have as many radio groups
on a page as you want, as long as each group has its own name.

Note: The value attribute defines the unique value
associated with each radio button. The value is not shown to the user, but is
the value that is sent to the server on “submit” to identify which radio button
that was selected.

Tip: Always add the <label> tag
for best accessibility practices!

Browser Support

Attribute

type=”radio”
Yes
Yes
Yes
Yes
Yes

Syntax

<input type=”radio”>

❮ HTML <input> type attribute

Alternate Text Gọi ngay