CSS Reference ยท Positioning and Stacking
The position-anchor property
Reference for the CSS position-anchor property: pick the default anchor element for a positioned box, how it relates to anchor-name, and browser support.
The position-anchor property selects the default anchor of an absolutely or fixed positioned element: the element, named with anchor-name, that it is positioned against. Once a default anchor is set, position-area and calls to anchor() without an explicit name refer to it.
With the initial value auto, the element uses its implicit anchor where one exists, for example the button that invokes a popover through popovertarget.
.tooltip { position: absolute; position-anchor: --help; position-area: bottom; }
Try it
Syntax
position-anchor: auto | <anchor-name>; position-anchor: --toolbar;
- Initial value:
auto - Applies to: absolutely positioned boxes (
absoluteorfixed) - Inherited: no
- Animatable: no (discrete)
- Computed value: as specified
Values
| Value | Description |
|---|---|
auto |
Use the implicit anchor, if the element has one (such as a popover's invoker). Otherwise there is no default anchor. |
<anchor-name> |
A dashed identifier matching an element's anchor-name. |
Usage notes
- Default, not exclusive.
anchor(--other top)can still name a different anchor explicitly, so one element can combine several anchors. - Needs a match. If no element has that name, the positioned element behaves as if it had no anchor and the anchor-based declarations are ignored or fall back, depending on the function used.
- Reusable components. Setting
position-anchorthrough a custom property lets one tooltip rule serve many triggers, as long as each trigger gets a uniqueanchor-name. - Combine with fallbacks. Pair it with
position-try-fallbacksso the box moves when it would overflow the viewport.
Browser support
Part of CSS anchor positioning, which Chromium browsers support from version 125 and Safari from version 26; other browsers are still catching up. Check a current compatibility table before relying on it.