Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

WebKit 8 min read How-to mediumAdept

A gentle introduction to anchor positioning

CSS anchor positioning lets you place an element, such as a popover menu or tooltip, relative to another element without JavaScript. You declare `anchor-name` on the anchor, `position-anchor` on the absolutely or fixed positioned target, and then place the target either with `position-area`, a nine-cell grid centered on the anchor, or with the `anchor()` function inside inset properties. Values like `block-end span-inline-end` give left-aligned dropdowns, and `position-try` supplies a fallback position when space runs out, for example on mobile. The examples favor logical values over physical ones, and `anchor()` can be combined with `calc()` for fine alignment offsets.

Related posts

  • Release Notes for Safari Technology Preview 227

    WebKit easyNovice

    Safari Technology Preview 227 (WebKit 298484@main…299099@main) adds the Navigation API, the scrollend event, command/commandfor button attributes for declarative popover and dialog control, and CSS field-sizing, scrollbar-color, position-visibility and math-shift. Anchor positioning now remembers the last successful position-try fallback and supports pseudo-elements. WebAssembly gains Memory toFixedLengthBuffer()/toResizableBuffer(). Fixes cover Animation.commitStyles(), anchor() in grid, CSP nonce handling for preload headers, storage access inheritance for WebSockets, and SVG spec conformance.

  • News from WWDC26: WebKit in Safari 27 beta

    WebKit mediumAdept

    Safari 27 beta ships 58 new features, 525 fixes and 4 deprecations, with most of the work going into correctness, edge cases, cross-feature interactions and alignment with web standards and other browsers. Headline features include customizable <select> via appearance: base-select with ::picker-icon, ::checkmark and <selectedcontent>, transform-aware anchor positioning, scroll anchoring, WebAssembly JSPI, the :heading pseudo-class, revert-rule, the stretch sizing keyword and subpixel inline layout. Anchor positioning also changes: position-anchor now defaults to normal, and anchors-valid/anchors-visible are renamed to anchor-valid/anchor-visible. Long lists of fixes cover CSS layout, :has() invalidation performance, SVG 2 alignment, tables and form controls.

  • A guide to Scroll-driven Animations with just CSS

    WebKit mediumAdept

    CSS scroll-driven animations, now supported in Safari 26 beta, tie keyframe animations to scroll position instead of time using the animation-timeline property, with no JavaScript required. A scroll-driven animation combines a target, keyframes and a timeline: scroll() advances with the scroller's position (shown with a footer progress bar), while view() advances as an element moves through the viewport (shown with images sliding in). animation-range limits when along the timeline the animation runs, for example 0% 50% so images settle halfway up the viewport. Note that animation-timeline must be declared after the animation shorthand, and larger motion effects should be wrapped in a prefers-reduced-motion media query.

  • Release Notes for Safari Technology Preview 243

    WebKit mediumAdept

    Safari Technology Preview 243 ships WebKit changes 310600@main through 312007@main for macOS Tahoe and Sequoia. The bulk of the release is CSS layout and selector fixes, covering flexbox, grid, aspect-ratio, anchor positioning, `:has()` invalidation and CJK line breaking. It also adds `contain: style` for quote counters, the `insert` keyword for `text-autospace` and the `shadowrootslotassignment` attribute. Other changes include accessibility fixes for VoiceOver, an O(n²) fix for parsing large `<select>` lists, an ES module loader rewrite for top-level await correctness, and several regular expression fixes.

  • Make creative borders with background-clip border-area

    WebKit mediumAdept

    `background-clip: border-area`, available in Safari Technology Preview and Safari 18.2 beta, clips a background image or gradient to the border region. That lets a single image, linear, conic or repeating gradient fill any border style, width, radius or subset of sides, unlike nine-slice `border-image`. The recipe is a transparent border, a background with `background-origin: border-box` (otherwise the padding-box origin repeats the background under the border), and the new clip value. Multiple background layers let it combine with `background-clip: text`, and feature queries provide progressive-enhancement fallbacks. Pending CSSWG changes will allow `border-area text` in one layer and default the origin to border-box.

The quest for software engineering knowledge.

Look:
Layout: