@@ -273,8 +273,8 @@ Container Queries</h2>
273273 A [=query container=] is established by specifying
274274 the possible query types using the 'container-type' property
275275 (or the 'container' [=shorthand=] ).
276- Style rules applying to its descendants can then be conditioned
277- by querying against it,
276+ Style rules applying to its <a>shadow-including descendants</a> can then be
277+ conditioned by querying against it,
278278 using the ''@container'' [=conditional group rule=] .
279279
280280 <div class=example>
@@ -303,6 +303,79 @@ Container Queries</h2>
303303 will each respond to their own container context.
304304 </div>
305305
306+ For selectors with pseudo elements, query containers can be established by
307+ the <a>shadow-including inclusive ancestors</a> of the <a>ultimate
308+ originating element</a> .
309+
310+ It follows that:
311+
312+ * Pseudo elements themselves can not be query containers
313+ * ''::before'' , ''::after'' , ''::marker'' , and ''::backdrop'' query their
314+ originating elements
315+ * ''::first-letter'' and ''::first-line'' queries its originating element,
316+ even if the <a>fictional tag sequence</a> may push the ''::first-line''
317+ past other elements for the purpose of inheritance and rendering
318+ * Multiple pseudo elements do not allow pseudo elements to be query
319+ containers for other pseudo elements. E.g., the host, but not the part()
320+ can be the query container for ''::before'' in ''host::part()::before''
321+ Similarly, the ''::before element'' can not be the query container for the
322+ ''::marker'' in ''div::before::marker''
323+ * ''::slotted()'' selectors can query containers inside the shadow tree,
324+ including the slot itself
325+ * ''::part()'' selectors can query its originating host, but not internal
326+ query containers inside the shadow tree
327+ * ''::placeholder'' and ''::file-selector-button'' can query the input
328+ element, but do not expose any internal containers if the input element is
329+ implemented using a shadow tree
330+
331+ <div class=example>
332+ A ::before selector querying the size of the originating element:
333+
334+ <pre class=lang-html>
335+ <style>
336+ #container {
337+ width: 100px;
338+ container-type: inline-size;
339+ }
340+ @container size(inline-size < 150px) {
341+ #inner::before {
342+ content: "BEFORE";
343+ }
344+ }
345+ </style>
346+ <div id=container>
347+ <span id=inner></span>
348+ </div>
349+ </pre>
350+ </div>
351+
352+ <div class=example>
353+ A ::slotted() selector for styling a shadow host child can query a
354+ container in the shadow tree:
355+
356+ <pre class=lang-html>
357+ <div id=host style="width:200px">
358+ <template shadowroot=open>
359+ <style>
360+ #container {
361+ width: 100px;
362+ container-type: inline-size;
363+ }
364+ @container size(inline-size < 150px) {
365+ ::slotted(span) {
366+ color: green;
367+ }
368+ }
369+ </style>
370+ <div id=container>
371+ <slot />
372+ </div>
373+ </template>
374+ <span id=slotted>Green</span>
375+ </div>
376+ </pre>
377+ </div>
378+
306379<h3 id="container-type">
307380Creating Query Containers: the 'container-type' property</h3>
308381
0 commit comments