Favorites

CSS position-anchor Property

position-anchor
CSS PropertyThis property is supported by all modern browsers.
Updated 22nd November 2026

The position-anchor property sets the default anchor of an anchor-positioned element, by its anchor-name.

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee

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

Anchor A
Anchor B
Tooltip
Demo Code
HTML Code
<div class="demo-area">
	<div class="demo-anchor demo-a">Anchor A</div>
	<div class="demo-anchor demo-b">Anchor B</div>
	<div class="demo-element">Tooltip</div>
</div>
CSS Code
.demo-area {
	position: relative;
	width: 300px;
	height: 190px;
	background: #f4f4f4;
	outline: 1px dashed #b0b0b0;
}
.demo-anchor {
	position: absolute;
	padding: 8px 12px;
	background: #e7ecff;
	border: 2px solid #4361ee;
	font-size: 14px;
}
.demo-a {
	left: 20px;
	top: 30px;
	anchor-name: --demo-a;
}
.demo-b {
	right: 20px;
	top: 90px;
	anchor-name: --demo-b;
}
.demo-element {
	position: absolute;
	margin: 4px;
	padding: 4px 8px;
	background: #f72585;
	color: #fff;
	font-size: 13px;
	white-space: nowrap;
	position-area: bottom;
	position-anchor: --demo-a;
}

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-name of the element to use as the default anchor.
  • initialSets the property to its initial value.
  • inheritTakes the computed value of the parent element.

Example

<div class="stage">
<button class="anchor">Anchor</button>
<div class="tip">Positioned against the button</div>
</div>
.stage {
  height: 180px;
  font-family: system-ui, sans-serif;
}

.anchor {
  anchor-name: --btn;
  margin: 40px 0 0 60px;
  padding: 10px 18px;
  font: inherit;
}

.tip {
  position: absolute;
  position-anchor: --btn;      /* tether to the button */
  top: anchor(bottom);
  left: anchor(center);
  translate: -50% 8px;
  padding: 6px 10px;
  background: #4361ee;
  color: #fff;
  border-radius: 6px;
  white-space: nowrap;
}
Open in editor

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.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee