Position-anchor - CSS Property

position-anchor

Summary of characteristics of the position-anchor property

Quick description
Defined in relation to which anchor the element should be positioned.
Status
Standard
Applies to
Elements positioned in fixed or absolute.
Predefined values
normal | auto | none | match-parent
Percentages
Not applicable.
Initial value
normal
Inherited by default
No.
Discrète: during an animation, the position-anchor property passes from one value to another without transition.
Single: single value (no order).
W3C Module
CSS Anchor Positioning
Document status: WD (Working Draft)

Syntax diagram of position-anchor.

Position-anchor property - Syntax diagramSyntax diagram of the anchor-name CSS property, which defines an identifier for the element that will serve as an anchor (anchor positioning) none none normal normal auto auto match-parent match-parent --id --idposition-anchor:;position-anchor:;
Syntax diagram of the position-anchor property.
The links in the diagram provide more details about the values.
Download the diagram.

In the diagram, the bold terms are the predefined words of CSS, the other terms are described below:

  • --id is an identifier defined by the property anchor-name.

Description of the position-anchor property.

This property is used in anchor positioning, which is an evolution of positioning with absolute or fixed (see the position property for that). It involves positioning an element relative to another one, which is called the anchor.

The anchor received an identifier (which starts with a double dash) through the anchor-name property. This is the identifier that should be given to the position-anchor property. Also, check out the anchor-name property page for a summary of the properties involved in anchor positioning and for a tutorial on anchor positioning.

Values for position-anchor.

  • position-anchor: none;

    No anchor is set by this element. The element isn't attached to any anchor.

    --syntax1
    ⚓
    position-anchor:none;
  • position-anchor: normal;

    If the property position-area is null, the value normal is equivalent to none; otherwise, it is equivalent to the value auto.
    For now, browsers don't make any distinction with the value none.

    --syntax2
    ⚓
    position-anchor:normal;
  • position-anchor: auto;

    This is the theoretical default value, but many browsers use none as the default. Some elements have automatic and predefined positioning. This is the case, for example, with bullets in a list, or with ::before and ::after elements. Other elements have the non-standard anchor attribute.
    For now, browsers don't make any distinction with the none value.

    --syntax3
    ⚓
    position-anchor:auto;
  • position-anchor: --id;

    The element will be positioned relative to the anchor with the ID --id.

    --syntax4
    ⚓
    position-anchor:--syntax4;
  • position-anchor: match-parent;

    The element follows the same positioning rules as its parent.

    --syntax5
    ⚓
    Texte du parent
    position-anchor:match-parent;
  • position-anchor: initial; (normal) position-anchor: inherit; position-anchor: revert; position-anchor: revert-layer; position-anchor: revert-rule; position-anchor: unset;

    See the following pages for more details: initial, inherit, revert, revert-layer, revert-rule, unset.

Animation of the position-anchor property.

Animating the position-anchor property is possible in discrete mode (sudden jump from one value to another). However, browsers based on -webkit- don’t seem to perform the animation.

--animation1
⚓
--animation2
⚓
--animation3
⚓
Text placed successively
under each of the anchors.

Browsers compatibility with position-anchor.

Browsers do recognize the position-anchor property, but many of them use none as the default value.

Column 1
General support for anchor positioning.
Column 2
Support for the position-anchor property that defines the anchor on which an element should be positioned.

Notes:

(1) Samsung Internet does not support the position-anchor property with the value normal. It also doesn't fully support the anchor-visibility property.

(2) Android browser does not support the position-anchor property with the value normal.
It also doesn't fully support the anchor-visibility property.

(3) Doesn't fully support the anchor-visibility property.

(4) Firefox does not allow animation of the anchor() and anchor-size() functions.
It does not fully support the anchor-visibility property.

(5) Opera does not support the position-anchor property with the value normal.
It also doesn't fully support the anchor-visibility property.

(6) The initial value is none instead of normal.

1
Anchor
positioning
2
position-anchor
property
Estimated overall support.
86%
71%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Samsung Internet

Androïd Brower

Chrome

Chrome pour Androïd

Edge

Firefox

Firefox pour Androïd

KaiOS Browser

Opéra

Safari

Safari sur IOS

Opéra mini

Historic of the position-anchor property.

  • CSS Anchor Positioning - Level 1

    Absolute positioning relative to the page or screen can prove to be limited when you want to position an element relative to another.
    This specification describes the properties necessary to achieve this, as well as the functions anchor() and anchor-size() that allow you to set the position and dimensions of an element based on another.
    It also describes how to test several positioning possibilities to adapt to the context, particularly to the state of the page scrolling.

    Regarding position-anchor First presentation of the property position-anchor which indicates on which anchor the element should position itself.
    WD
    June 29, 2023
    Working Draft.
    CR
    PR
    REC

See also, about anchor positioning.

Anchor positioning involves placing one element in relation to another. The specification CSS Anchor Positioning gathers all the properties and functions related to this feature.

Properties:

anchor-name
Sets an ID for the item, which can then become an anchor, in the context of anchor positioning.
anchor-scope
Defines the scope of the property anchor-name.
Position-anchor
Defined in relation to which anchor the element should be positioned.
position-area
Defines how an element is positioned relative to the anchor (above, beside, etc.).
position-try
Shorthand property that summarizes the values for position-try-fallbacks and position-try-order.
position-try-fallbacks
Specifies a list of positions for the positioned element (anchoring positioning) so that the browser can choose the one that is most suitable at any given moment, taking into account scrolls or zooms.
position-try-order
Defines a different order for the values listed by position-try-fallbacks.
position-visibility
Defines whether the positioned element is visible or not, in the context of anchoring positioning.

Functions:

anchor()
Returns the position of one of the edges of the element designated as the anchor (anchor-based positioning).
anchor-size()
Returns the size (height or width) of the element designated as the anchor (anchor-based positioning).

At-rules:

@position-try
Defines a set of rules for each anchor position and gives them a name (anchoring positioning).