CSS anchor positioning: place one element relative to another
Answer: CSS anchor positioning lets you declaratively place one element relative to another. Name the reference with anchor-name, starting with two dashes, then point at that name with position-anchor.
Naming an anchor and tethering to it
This CSS feature lets you declaratively position one element relative to another element.
Give the reference an anchor-name. That value is a string that starts with two dashes.
Take the positioned element out of normal flow with position set to absolute or to fixed.
Then set position-anchor to the name you assigned on the reference.
Anchors in the CSS API
This API lets you position elements relative to other elements, known as anchors.
The reference is designated as a reference point using the anchor-name property.
The unique identifier must be prepended with a double dash, much like a CSS variable.
Because the feature is built into the browser, layered interfaces do not have to rely on third-party libraries.
See also
Claims
- id: C1 claim: The feature declaratively positions one element relative to another. source: S1 evidence: "declaratively position an element relative to another element"
- id: C2 claim: An anchor-name value is a string that starts with two dashes. source: S1 evidence: "string that starts with two dashes"
- id: C3 claim: An anchor is designated as a reference point using anchor-name. source: S2 evidence: "designated as a reference point using the anchor-name property"
- id: C4 claim: The identifier must be prepended with a double dash. source: S2 evidence: "must be prepended with a double dash"
Sources
- [S1] Anchor positioning. web.dev. https://web.dev/learn/css/anchor-positioning . License: CC-BY-4.0. Accessed 2026-11-23.
- [S2] The CSS anchor positioning API. Chrome Developers. https://developer.chrome.com/docs/css-ui/anchor-positioning-api . License: CC-BY-4.0. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, Anchor positioning; Chrome Developers, The CSS anchor positioning API. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: web.dev, Anchor positioning; Chrome Developers, The CSS anchor positioning API. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC.
Cite this
iinventedlight. 2026. "CSS anchor positioning: place one element relative to another." iinventedlight Library, iil:note:2t5pc4jp, version of 2026-11-23. https://iinventedlight.com/library/notes/css-anchor-positioning/. License: CC-BY-4.0.
@misc{iil_note_2t5pc4jp,
author = {{iinventedlight}},
title = {{CSS anchor positioning: place one element relative to another}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/css-anchor-positioning/},
note = {Permanent ID iil:note:2t5pc4jp. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- css-anchor-positioning.schema.json (schema; CC-BY-4.0)
- css-anchor-positioning.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/css-anchor-positioning.md.