CKTIS / CSS
anchor-scope: keep repeated anchor names inside their component
Limit named-anchor definitions and lookups so that two components can safely reuse the same name.
Version: CSS Modules
Syntax
anchor-scope: none | all | --name [, --other-name]*;anchor-scope creates a local scope for selected anchor names within an element and its subtree. Its initial value none does not change the scope. Use a comma-separated list of dashed names to isolate those names, or all for all relevant names in the same tree scope. The property is not inherited; its effect comes from the scope it establishes, not from passing a value to children.
The boundary restricts both visibility of definitions and matching by descendants. It does not create an anchor: use anchor-name for that, and position-anchor or an explicit anchor() reference to select one. Normal anchor eligibility and layout rules still apply. Implicit anchors are unaffected, and tree-scope rules still matter across shadow boundaries. This is a layout naming mechanism, not a security boundary or a replacement for positioning.
The example repeats a component twice, with anchors at horizontal coordinates 20 and 200. Without a boundary, both local tips and an outside tip resolve the same name to the last eligible anchor: 200,200,200. Scoping the name on each component changes the result to 20,200,-999; the outside tip uses the explicit fallback because neither local definition is visible. Scoping all names gives the same measured result. These are actual layout coordinates in Chromium 157, not merely an accepted declaration.
Examples
document.body.style.margin='0';
const style=document.createElement('style');
style.textContent='.row{height:60px}.anchor{display:block;width:30px;height:20px;anchor-name:--item}.tip{position:absolute;left:anchor(--item left,-999px);top:anchor(--item bottom,-999px);width:10px;height:10px}';
document.head.append(style);
const rows=[],tips=[];
for(const x of [20,200]){const row=document.createElement('section');row.className='row';const anchor=document.createElement('span');anchor.className='anchor';anchor.style.marginLeft=x+'px';const tip=document.createElement('span');tip.className='tip';row.append(anchor,tip);document.body.append(row);rows.push(row);tips.push(tip)}
const outside=document.createElement('span');outside.className='tip';document.body.append(outside);
const measure=scope=>{for(const row of rows)row.style.setProperty('anchor-scope',scope);return [...tips,outside].map(el=>el.getBoundingClientRect().left).join(',')};
console.log('none='+measure('none')+'; named='+measure('--item')+'; all='+measure('all')+'; syntax='+CSS.supports('anchor-scope','--item'));Result
none=200,200,200; named=20,200,-999; all=20,200,-999; syntax=true
The anchors are sibling descendants of their component containers, not ancestors of the tips. The test deliberately uses a shared containing block, and -999px is an explicit diagnostic fallback rather than a recommended UI position.