CSS Anchor Positioning Lab
Experiment with anchor(), position-area and position-try fallbacks, then copy the CSS.
Anchor positioning is browser-dependent. The generated CSS is gated behind @supports and degrades to a static popover where unsupported.
Anchor controls
anchorThe stage is a schematic preview; exact placement depends on your browser's anchor-positioning support.
Generated CSS
validExamples
Tooltip
inset bottom: anchor(top); fallbacks flip-blockbottom: anchor(top, 0px);The tooltip sits above the trigger and flips when clipped.
Dropdown
position-area bottom span-right, anchor-size widthwidth: anchor-size(width);The menu starts at the anchor edge and shares its width.
Invalid name
anchorName: triggeranchor-name must be a custom identCustom idents start with two dashes.
About this tool
CSS Anchor Positioning Lab turns the new anchor-positioning syntax into a set of visible controls. Place a popover with anchor() insets or the three-by-three position-area grid, add an ordered position-try-fallbacks chain, choose a try order and size the target with anchor-size(). Every change is reflected immediately in copy-ready CSS.
The output is gated behind @supports (anchor-name: --x) so unsupported browsers simply keep their existing layout. Validation checks that anchor names are valid custom idents, flags duplicate or unusual fallback entries and explains when a value may need a browser-support check.
Presets cover the common patterns: a tooltip that flips, a dropdown that spans right and matches the trigger width, a select-like popover and a cursor badge. The schematic stage shows the relationship between the anchor and the anchored element; final placement is always the browser's decision.
What this tool does not do
- Browser support is partial; the generated CSS is gated behind @supports.
- The stage is schematic and does not reproduce browser overflow resolution.
- Custom @position-try blocks are not authored; use custom try names only.
- No shadow-DOM-specific cases are modeled.
How to use this tool
Choose a placement strategy
Use anchor() insets for explicit offsets or position-area for the keyword grid.
Configure the anchor
Enter a custom ident such as --trigger and set a margin around the anchored element.
Build fallbacks
List flip keywords, area keywords or custom --try names in the order the browser should try them.
Copy the CSS
Take the @supports-gated block into your stylesheet and optionally add the invoker markup.
Use cases
Design systems
Prototype tooltips and menus without JavaScript position calculations.
Teaching new CSS
Show how each declaration changes placement in one place.
Fallback planning
Check a flip chain before committing it to production styles.
Generated declarations
| Property | Example |
|---|---|
| anchor-name | --trigger |
| position-area | bottom span-right |
| inset | anchor(bottom, 0px) |
| position-try-fallbacks | flip-block, top center |
| anchor-size() | width |
| position-visibility | anchors-visible |
The CSS block is wrapped in @supports by default.
Common mistakes
Mistake:Using a plain ident for anchor-name.
Fix:Anchor names are custom idents such as --trigger.
Mistake:Forgetting a fallback inside anchor().
Fix:Provide a length like 0px so the position remains defined when anchoring fails.
Mistake:Assuming support everywhere.
Fix:Keep the @supports gate and a static fallback layout.
Mistake:Expecting exact positioning in the schematic stage.
Fix:The stage illustrates relationships; browsers decide final placement.
Frequently asked questions
Which browsers support anchor positioning?
Support is rolling out, with Chromium leading and other engines catching up. That is why the generated CSS is wrapped in @supports: unsupported browsers keep your existing layout instead of rendering a broken position.
How do fallbacks pick their order?
The browser walks position-try-fallbacks from first to last and picks the first position that fits the viewport. position-try-order can prefer the option with the most height, most width or least overlap.
Can I anchor a popover without JavaScript?
Yes. anchor-name on the trigger plus position-area or anchor() insets on the popover is pure CSS, and the popover attribute supplies show/hide behavior. The lab can include the invoker markup in its output.
What is position-area versus anchor()?
position-area places the target in a nine-cell grid around the anchor using keywords. anchor() computes a specific inset from an anchor edge and accepts a fallback length. Both are valid; area placement is often shorter.
Does it work inside shadow DOM?
Anchoring is scoped by tree boundaries, so cross-root anchoring needs special handling. This lab models the ordinary same-tree case and does not generate shadow-DOM-specific rules.
Is my CSS uploaded?
No. Every control, preview and CSS emission runs locally in your browser tab.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.