Anchor Positioning in CSS

From the CSS cheat sheet · Modern CSS Features · verified Jul 2026

Anchor Positioning

Position elements relative to other elements — no JS-based popper needed.

css
/* Step 1: name an anchor */
.button {
  anchor-name: --trigger;
}

/* Step 2: position something relative to that anchor */
.tooltip {
  position: absolute;
  position-anchor: --trigger;

  /* Place below the anchor, centered */
  top: anchor(bottom);
  left: anchor(center);
  translate: -50%;
}

/* Or use the high-level shorthand */
.popover {
  position: absolute;
  position-anchor: --trigger;
  position-area: bottom span-all;     /* below, full width */
}
💡 anchor-name declares the source; position-anchor + anchor() places relative to it
⚡ position-area is the easy mode — pick a region (bottom center, top left, etc.)
📌 position-try-fallbacks auto-flips to avoid overflow — kills the need for floating-ui
🔥 Pairs beautifully with native <dialog> and popover="" for tooltips/menus

More CSS tasks

Back to the full CSS cheat sheet