- From: Guillaume via GitHub <noreply@w3.org>
- Date: Fri, 13 Feb 2026 14:03:31 +0000
- To: public-css-archive@w3.org
cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:
== [selectors-4] Should `document.documentElement` match `:scope` when `document` is included `scoping roots`? ==
Otherwise I cannot understand how, following the corresponding definitions of HTML and Selectors, `document.querySelector(':scope')` can return `document.documentElement` (`:root`), which is apparently expected ([wpt.fyi](https://wpt.fyi/results/css/selectors/scope-selector.html?label=master&label=experimental&aligned), [WPT](https://github.com/web-platform-tests/wpt/blob/fe4dce2b727c90a812aad0d1a10cf70ab71c5ec1/css/selectors/scope-selector.html#L34)).
> In some contexts, selectors are matched with respect to one or more scoping roots, such as when calling the `querySelector()` method in [DOM]. The `:scope` pseudo-class represents this scoping root [...]
https://drafts.csswg.org/selectors-4/#the-scope-pseudo
My understanding is that `document` is [passed as](https://dom.spec.whatwg.org/#dom-parentnode-queryselector) [one of](https://dom.spec.whatwg.org/#scope-match-a-selectors-string) [the `scoping roots`](https://drafts.csswg.org/selectors-4/#match-a-selector-against-a-tree), and that none of the `candidate elements` match `:scope` since none is included in `scoping roots`.
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13494 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 13 February 2026 14:03:32 UTC