- From: Mason Freed <notifications@github.com>
- Date: Mon, 22 Apr 2024 16:53:38 -0700
- To: w3ctag/design-reviews <design-reviews@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 22 April 2024 23:53:42 UTC
> Quick question: Could you clarify the scope of anchor names? I see anchor names are defined as [tree-scoped](https://drafts.csswg.org/css-scoping-1/#css-tree-scoped-reference). Wouldn’t that mean that you can't have multiple elements with the same anchor name in each shadow tree or the entire light DOM? Reading the code I'd have expected that the identifier is scoped to the element it’s defined on and its descendants. So a few answers to this: 1. Yes they are tree scoped, but that doesn't mean you can't have multiple elements with the same anchor name. The ["target anchor element" algorithm](https://drafts.csswg.org/css-anchor-position-1/#target-anchor-element) finds the closest named anchor looking up the DOM tree. So you can construct repeating sections of `anchor-name`, `position-anchor`, `anchor-name`, etc., and each `position-anchor` will "find" the `anchor-name` just above it, which tends to be convenient in many circumstances. 2. The [`anchor-scope` property](https://drafts.csswg.org/css-anchor-position-1/#propdef-anchor-scope) allows developers to get the behavior you were hoping for, limiting name scoping to descendants. -- Reply to this email directly or view it on GitHub: https://github.com/w3ctag/design-reviews/issues/848#issuecomment-2071139463 You are receiving this because you are subscribed to this thread. Message ID: <w3ctag/design-reviews/issues/848/2071139463@github.com>
Received on Monday, 22 April 2024 23:53:42 UTC