CKTIS / CSS
CSS property `position-visibility`
`position-visibility` can conditionally give an absolute box computed `visibility` of `force-hidden`, rather than leave a label displayed without a useful anchor relationship.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
always | [ anchor-valid || anchor-visible || no-overflow ]position-visibility can conditionally give an absolute box computed visibility of force-hidden, rather than leave a label displayed without a useful anchor relationship.
The example uses an unresolvable default anchor: hit-testing skips the red box with anchor-valid, but hits the otherwise identical box with always.
Grammar: always | [ anchor-valid || anchor-visible || no-overflow ].
anchor-valid hides for an unresolved referenced anchor, anchor-visible for an invisible or fully clipped anchor, and no-overflow after overflow remains even after position tries. Keywords can be combined; always disables these conditions, but CSS creates no accessibility relationship between label and anchor.
Examples
<!doctype html><meta charset="utf-8"><style>html,body{margin:0}.stage{position:absolute;top:0;width:50px;height:100px;background:green}.box{position:absolute;width:50px;height:50px;background:red;position-anchor:--missing;top:anchor(bottom,50px);left:0}#conditionalStage{left:0}#alwaysStage{left:70px}#conditional{position-visibility:anchor-valid}#always{position-visibility:always}</style><div id="conditionalStage" class="stage"><b id="conditional" class="box"></b></div><div id="alwaysStage" class="stage"><b id="always" class="box"></b></div><pre id="result"></pre><script>requestAnimationFrame(()=>{const a=getComputedStyle(conditional).positionVisibility,b=getComputedStyle(always).positionVisibility,x=document.elementFromPoint(25,75)?.id,y=document.elementFromPoint(95,75)?.id;if(a!=='anchor-valid'||b!=='always'||x!=='conditionalStage'||y!=='always')throw new Error('visibility mismatch '+[a,b,x,y]);result.textContent='property='+a+'/'+b+'; hit='+x+'/'+y});</script>Result
property=anchor-valid/always; hit=conditionalStage/always
The example uses an unresolvable default anchor: hit-testing skips the red box with `anchor-valid`, but hits the otherwise identical box with `always`.