Anchor positioning lets an absolutely positioned box (absolute or fixed) place and size itself against another element's box, with no JavaScript measuring.
- Name the anchor.
anchor-name: --saveon the target. Names needn't be unique: the nearest ancestor wins, otherwise the last match in tree order.anchor-scope: --savelimits a name to a subtree, so repeated components don't collide. - Pick a default anchor.
position-anchor: --saveon the positioned box. Its initial value,normal, uses the element's implicit anchor whenposition-areais set: a popover opened by apopovertargetbutton (orshowPopover({ source })) gets that button as its implicit anchor. - Place it, two ways:
position-area: top(orbottom right,left span-bottom, …) picks cells of a 3×3 grid formed by the anchor's edges and the containing block's edges, and makes that area the containing block;autoinsets and margins become0. A singletopspans the full width and centres on the anchor.anchor()in an inset gives a length:top: anchor(bottom)puts the box's top at the anchor's bottom.anchor(--other right, 8px)names another anchor, with a fallback length.
- Size it with
anchor-size(width)in sizing properties, margins or insets. - Handle overflow.
position-try-fallbacks: flip-block, flip-inlineor named@position-tryrules give alternatives tried in order when the box overflows its inset-modified containing block.
By default (position-visibility), the box is hidden once its anchor is scrolled out of view or clipped.
The catch: an anchor must be laid out before the positioned box. Roughly, it must sit inside the positioned box's containing block; an anchor in a different position: relative card is invisible to it.
Support: Chrome 125, Firefox 147 and Safari 26; the normal initial value arrived in Chrome 151, Firefox 151 and Safari 27.