← All notes

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

Sources

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

Permanent ID: iil:note:2t5pc4jp

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.},
}

Markdown

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.

All artifact files (JSON index)

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.