Container Size Queries

Acceptable Support Updated: Jan 23, 2026

Enable querying the size of a defined container and responding to that size by applying rulesets to its children.

Baseline:
Widely
Functional:
Critical
Usage:
Cross-Boundary

Essential access to query light DOM-defined containers from within the shadow DOM is supported.

Additionally, most other queries for :host, ::slotted(), and ::part() defined containers will work as expected.

Web Platform Test
Chrome 148
Edge 148
Firefox 150
Safari 26.5
Outer scope query should match container-name set by ::slotted rule in shadow tree
pass
pass
pass
fail
Match container in outer tree
pass
pass
pass
pass
Match container in walking flat tree ancestors
pass
pass
pass
pass
Match container in ::slotted selector's originating element tree
pass
pass
pass
pass
Match container in outer tree for :host
pass
pass
pass
pass
Match container in ::part selector's originating element tree
pass
pass
pass
pass
Match container for ::before in ::slotted selector's originating element tree
pass
pass
pass
pass
Match container in outer tree for :host::before
pass
pass
pass
pass
Match container for ::before in ::part selector's originating element tree
pass
pass
pass
pass
Match container for ::part selector's originating element tree for exportparts
pass
pass
pass
pass
Match container for slot light tree child fallback
pass
pass
pass
pass
Should match container inside shadow tree for ::part()
pass
pass
pass
pass
A :host::part rule should match containers in the originating element tree
pass
pass
pass
pass
Container name set inside a shadow tree should match query using ::part on the outside
pass
pass
pass
pass
Container name set with a ::part should match query inside the shadow tree
pass
pass
pass
pass
Container name set inside a shadow tree should match query for a ::slotted() rule inside the tree
pass
pass
pass
pass
Container name set inside a shadow tree should match query for host child on the outside
pass
pass
pass
pass
Container name set on :host from inside a shadow tree matching query inside the shadow tree
pass
pass
pass
pass
Container name set on :host from inside a shadow tree matching query for ::slotted inside the shadow tree
pass
pass
pass
pass
Container name set on :host from inside a shadow tree should match query for slotted from the outside of the shadow tree
pass
pass
pass
pass
The originating element should be the first container candidate of ::before
pass
pass
pass
pass
Search flat tree anchestors of the originating element of ::before
pass
pass
pass
pass
Outer scope query should match container-name set by :host rule in shadow tree
pass
pass
pass
pass
Inner scope query should match container-name set by :host rule in shadow tree
pass
pass
pass
pass
Inner scope query containing ::slotted should match container-name set by :host rule in shadow tree
pass
pass
pass
pass
WPT sources: container-for-shadow-dom, container-name-tree-scoped