Core CSS

Tether floating tooltips and popovers natively without JavaScript positioning libraries

For years, whenever students wanted to pin a tooltip or flyout menu to a button, I had to tell them to install heavy JavaScript positioning libraries like Popper.js. CSS Anchor Positioning is one of the most exciting additions to the language—it lets the browser's compositor calculate viewport collisions and edge-flipping with zero JavaScript.

📖 Read the Complete Tutorial: CSS Anchor Positioning Guide →
CSS Anchor Positioning Playground
WordPress & Elementor Integration

How to Use CSS Anchor Positioning in Elementor

Tether floating popups, contextual dropdowns, and info tooltips directly to any Elementor button without JavaScript positioning calculations or clipping issues.

1

Configure & Copy Code

Pick your target role (dropdown, tooltip, flyout popover), docking side, alignment, and offset. Click the Elementor / WP tab and click Copy.

2

Embed HTML Snippet

Drag an HTML Widget anywhere onto your page and paste the code. The popup automatically pins to the designated trigger button using native W3C anchor().

3

Automated Collision Flipping

Our generated code includes @position-try rules, ensuring that when the user scrolls near the screen edge, the popup automatically flips to the opposite side.

💡
Cross-DOM Tethering: Anchor Positioning completely ignores parent container overflow: hidden restrictions. You can anchor an element residing in a top-layer popover or page footer directly to a button inside a nested card.

Frequently Asked Questions

Which browsers natively support CSS Anchor Positioning?

CSS Anchor Positioning is supported out of the box in Google Chrome 125+, Microsoft Edge 125+, and Chromium-based browsers. It is actively in development in Safari WebKit and Firefox Gecko. For complete backwards compatibility, the lightweight @oddbird/css-anchor-positioning polyfill provides transparent polyfilling in older engines.

How does @position-try handle screen edge collisions?

When a popup element uses position-try-fallbacks, the browser tests the preferred positioning first. If the target overflows the viewport, the layout engine automatically evaluates each fallback rule in order (such as flipping from bottom to top), choosing the first rule that fits comfortably within the visible screen area.

Can an anchor element be outside the target's DOM container?

Yes! That is the defining superpower of CSS Anchor Positioning. You can place your tooltip or dialog inside a top-level <body> or <dialog> container, and anchor it directly to a button deeply nested inside an article, card, or navigation header.

What is CSS Anchor Positioning and how does it replace JavaScript tooltip libraries?

CSS Anchor Positioning allows an absolutely positioned element (tooltip, popover, menu) to tether directly to any target element on the page using anchor-name and position-anchor, eliminating third-party JS libraries like Floating UI.

How do I anchor a tooltip above a button with pure CSS?

Set anchor-name: --my-btn; on the button. On the tooltip, declare position: absolute; position-anchor: --my-btn; bottom: anchor(top); justify-self: anchor-center;. The tooltip docks above the button automatically.

How does CSS Anchor Positioning handle viewport edge flipping?

Use position-try-fallbacks: flip-block, flip-inline;. When scrolling near the top of the screen, the browser automatically flips the tooltip from top to bottom to prevent it from clipping off-screen.

Can anchor positioning tether elements across different DOM hierarchy levels?

Yes. Unlike traditional CSS positioning where children are trapped by overflow: hidden parents, anchor positioning allows elements in the top-layer popover to anchor to targets anywhere in the DOM tree.

How do I use CSS Anchor Positioning in Elementor?

Drag an HTML widget into your Elementor template and paste the code from the Elementor / WP tab. It utilizes W3C anchor-name and position-anchor to pin floating badges, tooltips, or popups directly to any target button with automated @position-try edge-flipping fallbacks.