Group related controls with fieldset and legend—the accessible pattern for radio clusters, address blocks, and payment sections. Pico styles legends with the same visual weight as form labels.
Horizontal groups
Use role="group" on a wrapper (often the fieldset itself) to stack buttons or inputs in a row—search bars, prefix + input combos, and button toolbars. Unlike class="grid", groups do not collapse on small screens; reserve them for short control clusters.
Grid inside forms
Pico’s class="grid" inside a form splits fields into columns at wider viewports—handy for city/state/ZIP rows while keeping one semantic form.
Important interview questions and answers
- Q: Why fieldset instead of nested divs?
A: Screen readers announce the group boundary and legend; divs need extra ARIA to match that behavior. - Q: When use
role="group"vsgrid?
A:role="group"for inline toolbars and compact rows;gridfor responsive multi-column field layout.
Self-check
- Which element names a related set of radio buttons for assistive tech?
- What role stacks a search input and button on one line?