CSS Anchor Positioning Guide | CSS-Tricks

October 4, 2024

CSS Anchor Positioning gives us a simple interface to attach elements next to others just by saying which sides to connect — directly in CSS. It also lets us set a fallback position so that we can avoid the overflow issues we just described. For example, we might set a tooltip element above its anchor but allow it to fold underneath the anchor when it runs out of room to show it above.

Anchor positioning is different from a lot of other features as far as how quickly it’s gained browser support: its first draft was published on June 2023 and, just a year later, it was released on Chrome 125. To put it into perspective, the first draft specification for CSS variables was published in 2012, but it took four years for them to gain wide browser support.So, let’s dig in and learn about things like attaching target elements to anchor elements and positioning and sizing them.

Source: CSS Anchor Positioning Guide | CSS-Tricks

Juan Diego Rodríguez gets us up to speed with anchor positioning, a sophisticated new CSS layout technology that allows us to do things until now we’d need JavaScript for.