Problem Statement
What type attribute value creates radio buttons?
Explanation
The input type equals radio creates radio buttons in HTML forms. Radio buttons allow users to select only one option from a group of choices. All radio buttons in a group must have the same name attribute but different value attributes. When one radio button is selected, any previously selected button in the same group is automatically deselected. This makes radio buttons perfect for mutually exclusive choices like gender, payment method, or subscription plan. Radio buttons are typically displayed as small circles that fill in when selected. You should always provide labels for radio buttons to make them easier to click and accessible to screen readers. Use radio buttons when you have a small number of options, typically two to seven, and users must select exactly one.
Code Solution
SolutionRead Only
<!-- Radio button group -->
<form>
<fieldset>
<legend>Select your gender:</legend>
<label>
<input type="radio" name="gender" value="male">
Male
</label>
<label>
<input type="radio" name="gender" value="female">
Female
</label>
<label>
<input type="radio" name="gender" value="other">
Other
</label>
</fieldset>
</form>
<!-- With default selection -->
<form>
<label>
<input type="radio" name="plan" value="basic">
Basic Plan
</label>
<label>
<input type="radio" name="plan" value="pro" checked>
Pro Plan (Selected by default)
</label>
<label>
<input type="radio" name="plan" value="enterprise">
Enterprise Plan
</label>
</form>