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