← Topic directory
CSS Anchor Positioning
Tethering elements to an anchor: position-area, anchor(), anchor-name, and position-try for tooltips, popovers, and menus.
13 features tagged with this topic.
Cross-browser consensus
- Firefox: No signal (9), Positive (4)
- Safari: No signal (8), Support (4), Shipped/Shipping (1)
- Web developers: No signals (11), Strongly positive (2)
Features by stage
Enabled by default (4)
Allow anchor-size() values for inset and margin properties.
Originally, anchor-size() was only allowed in sizing properties. The specification was changed to allow anchor-size() in insets and margins as well.
The anchor-scope property allows limiting the visibility of anchor names to a given subtree.
Replaces the inset-area() function with inset-area values directly within position-try-fallbacks. This means that you now just write e.g. position-try-fallbacks:top instead of position-try-fallbacks:inset-area(top).
The CSSWG resolved to rename this property, because "fallbacks" more accurately describes what this property controls. The word "options" is a bit deceiving, since the styles outside of `position-try` blocks will be tested first, and if they result in a layout that fits within the containing block, none of the "options" will get used. So "fallbacks" is a better word to describe this behavior.
https://github.com/w3c/csswg-drafts/issues/10395#issuecomment-2192127524
One note for developers: there is a `position-try` shorthand (see https://drafts.csswg.org/css-anchor-position-1/#position-try-prop) that can be used to help this migration. If you set `position-try` instead of `position-try-options` *or* `position-try-fallbacks`, the shorthand will set the proper longhand before and after this rename.
In developer trial (Behind a flag) (3)
CSS anchor positioning allows authors to "tether" an absolutely positioned element to one or more other elements on the page (the "anchors"), in a declarative way, without the use of Javascript. Anchor positioning works performantly when the anchors are scrollable. A common use case is to position a popover such as a tooltip next to the element that invoked it, or a select menu and its popover options list. Before the anchor positioning feature, these use cases required Javascript to dynamically position the popover, and keep it anchored as the invoking element was scrolled, which is a performance footgun and difficult to get right. With anchor positioning, these use cases can be implemented performantly and declaratively.
The anchor positioning feature consists of a large number of CSS properties, which are fully described in the spec (https://drafts.csswg.org/css-anchor-position-1). A few of the key features/properties include:
- `anchor-name`: sets up an element to be an anchor for other elements.
- `position-anchor`: describes the "default" anchor that an anchored element should use for anchor positioning.
- The `anchor()` function: used to refer to the position of the anchor element, in positioning the anchored element.
- `inset-area`: a shorthand for positioning, for common relative positions.
...and many more.
Also tagged: JavaScript Language Performance & Scheduling
Add support for the concept of "remembered scroll offset" - see https://drafts.csswg.org/css-anchor-position-1/#scroll
When a positioned element has a default anchor, and is tethered to this anchor at one edge, and against the original containing block at the other edge, the scroll offset will be taken into account when it comes to sizing the element. This way a developer can use all visible space (using `position-area`) for the anchored element when the document is scrolled at a given scroll offset.
In order to avoid layout (resizing the element) every time the document is scrolled (which is undesired behavior, and also bad for performance), what will be used is a so-called "remembered scroll offset", rather than always using the current scroll offset. The remembered scroll offset is updated at a so-called "anchor recalculation point", which is either:
- When the positioned element is initially displayed
- When a different position option (`position-try-fallbacks`) is chosen
Also tagged: Performance & Scheduling
This chromestatus represents the following related set of changes, which were resolved in https://github.com/whatwg/html/pull/9144#issuecomment-2195095228 and landed in https://github.com/whatwg/html/pull/10728:
1. add an imperative way to set invoker relationships between popovers: popover.showPopover({source})
2. invoker relationships create implicit anchor element references.
Also tagged: JavaScript Language
Proposed (5)
When an anchor-positioned element is tethered against an anchor that has a transform (or is contained by something with a transform), resolve anchor() and anchor-size() functions against the bounding box of the transformed anchor.
See the discussion in this issue for more context:
- https://github.com/w3c/html-aam/issues/545
The code to create aria-details relationships for non-popover use cases of anchor positioning was likely a mistake. Since popovers and other semantic relationships *do* create aria-details, and the remaining use cases are likely non-semantic, there is a desire *not* to create these relationships in the non-semantic cases.
Since most common use cases use popovers, this change should hopefully not be too noticeable to users.
A menu is a way to group menu items together and provide users the ability to execute commands. The existing <menu> element represents a “toolbar” listing of commands, and despite its name, it is not programmatically exposed as a "menu" or "menubar" to accessibility tools, or the web platform. Furthermore, there is no native support to make listed commands look and behave cohesively.
New menu elements make it easier for developers to follow ARIA practices on menu and menubar, while taking advantage of new web platform features that underpin menu systems. These elements include `<menubar>`, `<menulist>`, and `<menuitem>` elements.
These elements expand on the baseline behaviors popover and anchor positioning provide, and come with expected keyboard navigation behavior out of the box, ensuring consistent experiences for users of all kinds, on the platform they are engaging with.
The CSSWG resolved to rename `anchors-valid` --> `anchor-valid` [1] and `anchors-visible` --> `anchor-visible` [2]. To accomplish this, we'll rename the properties to the singular variants, and add aliases from the plural versions to the singular versions. At a later date, we will remove the plural variants. This chromestatus is only about shipping the new versions, and deprecating the old ones (but not removing them).
[1] https://github.com/w3c/csswg-drafts/issues/10201#issuecomment-4180411971
[2] https://github.com/w3c/csswg-drafts/issues/10201#issuecomment-4390233490
Resolve naming conflicts when multiple timelines in scope match a given name. In the case of a conflict, the last match in flat tree order wins. This updated behavior aligns with anchor positioning.
Previously, when multiple elements matched an animation-timeline name, the deferred timeline was left unresolved. The behavior has been clarified in:
https://github.com/w3c/csswg-drafts/issues/12581
Though the issue was filed for timeline-triggers rather than scroll animations, the same rules apply to both.
This change will not cause a resolved timeline to resolve to a different timeline, but allow a timeline that was previously unresolved to become resolved in the event of a conflict.
This was flagged as part of interop 2026 for scroll-animations.
Removed (1)
The CSSWG resolved to rename the `inset-area` property to `position-area`. See the CSSWG discussion here: https://github.com/w3c/csswg-drafts/issues/10209#issuecomment-2221005001. The new property name, `position-area`, as a synonym for `inset-area` shipped via https://chromestatus.com/feature/6567965055778816. This entry is for deprecation and removal of the `inset-area` property.
Timeline