Skip to content
Astera Technology

Give independent radio groups different names

Keep a text-size choice and an ink choice independent by using separate radio names.

Two native radio groups; changing ink does not clear text size.

Download complete case notes and answer keys ↓

Inspect the working example

Two fieldsets organize the controls visually and provide legends. The radio names establish separate groups in this one-document fixture: size and ink. Start with Small and Dark selected, then select Large and Green.

Inputs and native observations
CaseInput or inspectionResult and meaning
Initial stateInspect checked controlssmall and dark are checked
Select LargeActivate largelarge and dark remain checked
Then select GreenActivate greenlarge and green checked; small and dark unchecked
Download editable CSV ↓

Follow the browser mechanism

Radio group membership depends on factors including name, tree and form owner. All controls here share a tree and have no form owner, so different names keep the groups separate. Fieldsets alone do not override matching names. This fixture changes native selection only; it does not apply a text theme to the rest of the page.

Separate fieldsets do not separate matching names

Both controls below use name="choice" despite separate fieldsets. Picking Green clears Large in this shared-tree, no-form-owner case.

Counterexample source; inspect separately
<fieldset><legend>Text size</legend><label><input id="large" type="radio" name="choice" checked>Large</label></fieldset><fieldset><legend>Ink</legend><label><input id="green" type="radio" name="choice">Green</label></fieldset>

After selecting Green, only green is checked. The fieldsets did not preserve two independent choices.

Try the repair

You add Medium as a third size option. Which name should it use, and should choosing it affect Green?

Show the worked answer

Use name="size" so Medium replaces the currently selected size. Green keeps name="ink" and remains selected.

  • Check the four-control checked-state sequence after each choice.
  • Use labels and legends that identify the actual choices.

Original example files

Related resources