CSS position-anchor Property
The position-anchor property sets the default anchor of an anchor-positioned element, by its anchor-name.
Description
The position-anchor property sets the default anchor of an absolutely or fixed positioned element: the anchor element it is tethered to when the anchor() and anchor-size() functions are used without a name, and the element that position-area positions against.
The anchor is referenced by the name given to it with anchor-name. For example an anchor with anchor-name: --menu-button and a popup with position-anchor: --menu-button can then use top: anchor(bottom) or position-area: bottom to sit directly below the button, and the popup follows the button wherever it moves, including during scrolling.
The initial value is normal, which uses an implicit anchor if the element has one (for example a popover opened by a button with popovertarget, or a ::picker() attached to its select) and otherwise no anchor. Older browser versions used auto or none as the initial value. The property only has an effect on absolutely or fixed positioned elements.
Definition
- Initial value
- normal
- Applies to
- absolutely positioned elements
- Inherited
- no
- Computed value
- as specified
- Animatable
- discrete
- JavaScript syntax
- object.style.positionAnchor
Interactive Demo
Syntax
position-anchor: normal | none | auto | <anchor-name>;
Values
- normalThe default. Uses the implicit anchor element if there is one, otherwise there is no default anchor.
- noneThe element has no default anchor, even if an implicit anchor exists.
- autoUses the implicit anchor element, such as the invoker of a popover.
- <anchor-name>A <dashed-ident> matching the
anchor-nameof the element to use as the default anchor. - initialSets the property to its initial value.
- inheritTakes the computed value of the parent element.
Example
Browser Support
The following information will show you the current browser support for the CSS position-anchor property. Hover over a browser icon to see the version that first introduced support for this CSS property.
Desktop





Tablets & Mobile





