Input Types
HTML input type="radio"
Choose one option in a group. Give the related controls the same name and distinct values. Group membership depends on name, form owner and tree. required means a selection is needed in the group. Use only attributes applicable to this input state; the browser ignores or rejects unrelated constraints. Validate submitted data on the server.
Formal Syntax & Structure
html syntaxhtml
<input type="radio">Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| type | literal radio | Selects the radio input state. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| value | element-dependent text or number | Default value or submitted value depending on type. A file input cannot be prefilled with a path. |
| checked | boolean | Sets the default checked state for a checkbox or radio input. The current checked state is a DOM property and may change independently after user interaction. |
| required | boolean | Makes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation. |
Return Value
HTMLInputElement
Void form-associated element; no child content. The DOM value and form-submission behavior depend on the input state.
Working Example
Example Snippethtml
<fieldset> <legend>Delivery</legend> <label> <input type="radio" name="delivery" value="pickup" checked> Pickup </label> <label> <input type="radio" name="delivery" value="ship"> Ship </label></fieldset>