Skip to content
Tutorials Center
My learning

Topics

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.

CSS
.tooltip {
  position: absolute;
  position-anchor: --help;
  position-area: bottom;
}

Try it

Two tooltips, two anchors

Syntax

CSS
position-anchor: auto | <anchor-name>;

position-anchor: --toolbar;
  • Initial value: auto
  • Applies to: absolutely positioned boxes (absolute or fixed)
  • 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-anchor through a custom property lets one tooltip rule serve many triggers, as long as each trigger gets a unique anchor-name.
  • Combine with fallbacks. Pair it with position-try-fallbacks so 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.