Skip to content
Astera Technology

Highlight a field group while its child has focus

Follow the border state while focus moves between two grouped fields and one outside field.

Group border is green for either inside field and gray for the outside field.

Download complete case notes and answer keys ↓

Inspect the working example

The fieldset has two labeled text inputs. A separate input sits outside. focus-within changes the group border, while the input’s own focus indicator remains available.

Inputs and native observations
CaseInput or inspectionResult and meaning
Title focusFocus titleGroup matches :focus-within; green
Summary focusFocus summaryGroup still matches; green
Outside focusFocus outsideGroup no longer matches; gray
Download editable CSV ↓

Follow the browser mechanism

:focus-within matches an element when it or a relevant descendant is focused. :focus alone is a different condition. This is one selector mechanism, not the existing end-to-end keyboard acceptance journey.

Container :focus does not follow child focus

The alternative replaces focus-within with focus on the same fieldset.

Counterexample source; inspect separately
<style>body{margin:8px}</style>
<style>fieldset{border:3px solid rgb(140,140,140)}fieldset:focus{border-color:rgb(0,80,40)}</style><fieldset><legend>Workshop note</legend><label>Title <input id="title" type="text"></label></fieldset>

Focusing Title does not focus the fieldset itself, so the group stays gray.

Try the repair

Does a green group border replace the need for visible focus on the actual control?

Show the worked answer

No. It identifies the group, not the exact control. Keep and test the input focus indicator separately.

  • Check activeElement and group border for all three fields.
  • Keep the native field label and focus indicator.

Original example files

Related resources