DEV Community

A11Y Practice
A11Y Practice

Posted on Originally published at wasexamprep.com

Finding Radio Groups With No Question: A Console Check, the Accessibility Tree, and the Second-Option Trap

A bug a quick screen reader pass can miss

In Broken Case 1 of the Fieldsets & Legends lab, a bold "Shipping method" paragraph sits above two radio buttons in plain divs. The lab's VoiceOver on Mac capture (docs/voiceover/forms/fieldsets-legends/broken-output.md) reads:

Standard, selected, radio button, 1 of 2
Express, selected, radio button, 2 of 2
Enter fullscreen mode Exit fullscreen mode

The fixed version wraps the same radios in a fieldset with a legend. Its capture (fixed-output.md):

Standard, selected, radio button, 1 of 2, Shipping method, group
Express, selected, radio button, 2 of 2
Enter fullscreen mode Exit fullscreen mode

Look at the second line of each. They are identical. If you test by landing on the second option, the broken and fixed versions sound the same.

The companion blog post covers the rule (WCAG 2.2 SC 1.3.1 Info and Relationships) and the fix. This article is about testing for it: a manual routine, a console check you can paste into DevTools, what that check cannot see, and the mistakes that bring the bug back.

All script runs below are one browser (headless Chrome 156), on 29 November 2026: the live lab, plus a small local test page. The VoiceOver strings are the lab's own capture docs; I did not record new ones.

What exactly to check

1.3.1 says: "Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text." For a set of radio buttons or checkboxes, that becomes:

  1. Does each option have its own accessible name? (Usually yes: a <label> does that.)
  2. Is there a group container around the options in the accessibility tree?
  3. Does that group have a name, and does the name match the visible question?
  4. Is the group scoped to one question, not the whole form?

Most broken forms pass check 1 and fail check 2 or 3. That is why "every input has a label" audits miss this bug.

The manual routine first

  1. Turn VoiceOver on (Cmd+F5) and Tab into each radio or checkbox group from the field before it.
  2. Listen to the whole announcement of the first option. In the lab's captures the group name comes last: "..., Shipping method, group".
  3. Do not judge by a later option. In the captures, Express, SMS and PayPal sound the same in broken and fixed.
  4. In Chrome DevTools, select an option and open the Accessibility pane. Expand the ancestors: you want a group or radiogroup whose Name is the visible question.
  5. Check every visible bordered box. In the lab's Broken Case 3, a real fieldset with a paragraph instead of a legend shows up as a group with an empty name.
  6. Note the question text on screen and compare it with the group name. "Group" with no name, or a name that does not match, is a finding.

A console check for radio sets

Steps 4 and 5 get slow on a long form. This snippet lists every radio set on the page (radios grouped by form and name) and the group name a script can see for it. Paste it into the DevTools Console:

// Lists every radio set and the group name a script can see for it.
// A heuristic, not a full accessible-name computation:
// confirm anything it flags in the Accessibility pane.
(() => {
  const textOfIds = (ids) =>
    ids.split(/\s+/)
      .map((id) => document.getElementById(id)?.textContent.trim() ?? "")
      .join(" ")
      .trim();
  const groupOf = (input) => {
    const g = input.closest('fieldset, [role="radiogroup"], [role="group"]');
    if (!g) return { container: "(none)", name: "", note: "" };
    let name = "";
    let note = "";
    const labelledby = g.getAttribute("aria-labelledby");
    if (labelledby) name = textOfIds(labelledby);
    if (!name) name = (g.getAttribute("aria-label") || "").trim();
    if (!name && g.localName === "fieldset") {
      const legend = g.querySelector(":scope > legend");
      if (legend) {
        name = legend.textContent.trim();
        if (g.firstElementChild !== legend) note = "legend is not the first child";
      }
    }
    const role = g.getAttribute("role");
    return { container: g.localName + (role ? `[role=${role}]` : ""), name, note };
  };
  const sets = new Map();
  for (const r of document.querySelectorAll('input[type="radio"]')) {
    const key = r.name
      ? `${r.form ? [...document.forms].indexOf(r.form) : "-"}:${r.name}`
      : r;
    if (!sets.has(key)) sets.set(key, []);
    sets.get(key).push(r);
  }
  const rows = [...sets.values()].map((radios) => {
    const g = groupOf(radios[0]);
    return {
      name: radios[0].name || "(no name attribute)",
      options: radios
        .map((r) => r.labels?.[0]?.textContent.trim() || "(no label)")
        .join(" / "),
      container: g.container,
      groupName: g.name || "(none)",
      flag: g.name ? g.note : "NO GROUP NAME",
    };
  });
  console.table(rows);
  return rows;
})();
Enter fullscreen mode Exit fullscreen mode

On the live lab (headless Chrome 156, 29 November 2026) it returned:

name options container groupName flag
shipping Standard / Express (none) (none) NO GROUP NAME
payment Credit card / PayPal fieldset (none) NO GROUP NAME
fieldsets-legends-shipping Standard / Express fieldset Shipping method
fieldsets-legends-payment Credit card / PayPal fieldset Payment method

That matches Chrome's own accessibility tree for the same page: no group for Broken Case 1, a group with an empty name for Broken Case 3, and named groups in the fixed example.

On a local test page with three extra patterns, it returned:

Markup Result
div role="radiogroup" with aria-labelledby pointing at the question groupName "Shipping method" (Chrome's tree: radiogroup "Shipping method")
fieldset with a <p> before the <legend> groupName "Gift wrap", flag "legend is not the first child"
A single radio with no name flagged NO GROUP NAME (a false positive if it really stands alone)

What the check cannot see

  • It is not the browser's name computation. It reads aria-labelledby, aria-label and the fieldset's legend. Hidden elements, aria-labelledby pointing at missing ids, and other edge cases need the Accessibility pane. Treat a flag as "look here", not as a verdict.
  • It does not judge the name. "Group 1" passes the script. Only you can compare the group name with the visible question.
  • It does not cover checkboxes. Checkboxes have independent names, so a script cannot tell which ones belong together. Check checkbox groups by hand (manual step 4). In the lab's Case 2 capture, the broken checkbox has no position count to hint at a set at all: Email, unchecked, checkbox.
  • It does not see custom radios. Divs with role="radio" are a different bug class (missing native semantics). Extend the selector if your codebase uses them, and see Episode 7.
  • It is not a screen reader test. What VoiceOver announces, and when, is a separate observation. The lab's captures show the group name on the first option only; that is one setup, not a rule for every screen reader.

Common mistakes, and the check that catches each one

Mistake Why it happens Check that catches it
Question as a bold <p> or heading above plain divs It looks right, and every input has a label Console check: NO GROUP NAME, container (none)
fieldset with no legend The border came from a design system component Console check: container fieldset, NO GROUP NAME; Accessibility pane: group with empty name
legend not the first child of the fieldset A wrapper or helper text added above it Console check flag; H71 says the legend must come first
Testing only the second option Arrowing through a group already in progress Listen from the first option; confirm in the tree
Treating "1 of 2" as proof of grouping Position comes from the shared name attribute Look for a named group in the tree, not a count
One fieldset around the whole form "Group everything" sounds safe Each question gets its own group; H71 warns against unnecessary nesting
role="group" on a radio set Copied from a checkbox pattern ARIA17 says to use role="radiogroup" for radio buttons
aria-labelledby pointing at an id that changed Ids generated per render or renamed Accessibility pane: group Name empty
A long instruction paragraph as the legend Trying to fit help text into the group name Keep the legend to the question; put instructions elsewhere
A fieldset around a single checkbox Applying the pattern everywhere A lone checkbox needs only its own label

What each check can establish

  • The manual routine: what one screen reader announced in your setup, and what the tree exposes in your browser.
  • The console check: a fast list of radio sets with no name a script can see, in one browser, for native radios only.
  • The accessibility tree: whether a named group exists. For 1.3.1, this is the evidence to put in the report.
  • A VoiceOver capture: what one screen reader said in one setup. It shows the impact, but the second-option trap shows why it is not enough on its own.

Keep practicing

Practice this in the Fieldsets & Legends lab on wasexamprep.com, and read the companion post for the rule and the fix.

Watch the full walkthrough and subscribe to the A11Y in Practice YouTube channel for more hands-on accessibility episodes.

A11Y in Practice and wasexamprep.com are independent educational resources. They are not affiliated with or endorsed by IAAP (International Association of Accessibility Professionals).

Top comments (0)