Anchor positioning links a positioned element to a named anchor. The trigger declares anchor-name; an absolutely or fixed positioned hint declares position-anchor and uses anchor() or position-area to locate itself relative to the trigger.
CSS anchor positioning: place a hint beside its control
When to use it
A case-status button opens a short explanatory hint. The base layout keeps the hint in normal flow below the control, so unsupported browsers still show the text. An @supports block activates absolute positioning and tethers it to the named trigger. The component has a positioning context and enough room in the design for the hint; real overlays near viewport edges need collision handling and may need a top-layer primitive. Test the first and last row, narrow screens, zoom, scrolling ancestors, and repeated rows. Anchor names can collide across repeated components, so do not assume the nearest visual button is always selected when names are reused. Scope names or give each instance a distinct name where the browser and component model allow it. The button must still control visibility and focus access; CSS anchoring only chooses coordinates.
.status-help { position: relative; }
.status-help__hint { margin-block-start: .5rem; }
@supports (top: anchor(bottom)) { .status-help__trigger { anchor-name: --status-trigger; } .status-help__hint:not([hidden]) { position: absolute; position-anchor: --status-trigger; top: anchor(bottom); left: anchor(left); margin-block-start: .4rem; } }Cost and verification
An anchored element can avoid manual coordinate calculations, but it still needs space, stacking, overflow, and collision review. An absolutely positioned hint does not reserve space in the surrounding flow, so a low row may overlap later content. Repeated anchors with the same name can bind unexpectedly; test several instances together rather than one isolated example. If support is missing, the in-flow hint remains readable. Do not make a critical error message depend on a hover-only overlay or on anchor support. Profile and simplify if dozens of live overlays are open; the user usually needs one contextual hint at a time.
Common Mistakes
- Do not treat anchor positioning as a visibility or focus manager.
- Do not reuse an unscoped anchor name across repeated rows without testing binding.
- Do not assume an absolutely positioned hint reserves layout space.
