You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[selectors-4] Make specificity of :matches(), :has(), and :nth-child() not depend on matching. (Use most specific argument, like :not().) #1027 (comment)
Note: The specificity of the '':nth-child()'' pseudo-class is
2810
-
the specificity of a single pseudo-class plus
2811
-
the specificity of its selector argument <var>S</var>, if any.
2811
+
the specificity of a single pseudo-class plus,
2812
+
if <var>S</var> is specified,
2813
+
the specificity of the most specific <a>complex selector</a> in <var>S</var>.
2812
2814
See [[#specificity-rules]].
2813
2815
Thus ''<var>S</var>:nth-child(<var>An+B</var>)''
2814
2816
and '':nth-child(<var>An+B</var> of <var>S</var>)''
@@ -3310,25 +3312,16 @@ Calculating a selector's specificity</h2>
3310
3312
A few pseudo-classes provide “evaluation contexts” for other selectors,
3311
3313
and so have their specificity defined by their contents and how they match:
3312
3314
3313
-
ISSUE: See also <a href="https://github.com/w3c/csswg-drafts/issues/1027">issue 1027</a>.
3314
-
3315
3315
<ul>
3316
3316
<li>
3317
-
The specificity of a '':matches()'' or '':has()'' pseudo-class is replaced by
3318
-
the specificity applicable to its selector list argument.
3319
-
(When '':matches()'' contains only compound selectors,
3320
-
the full selector's specificity is thus equivalent to
3321
-
expanding out all the combinations in full, without '':matches()'';
3322
-
fully generalized, the specificity of '':matches()'' is
3323
-
the specificity of the most specific selector within it that matches.
3324
-
The behavior for comma-separated arguments to '':has()'' is analogous.)
3317
+
The specificity of a '':matches'', '':not()'', or '':has()'' pseudo-class
3318
+
is replaced by the specificity of
3319
+
the most specific complex selector in its selector list argument.
3325
3320
<li>
3326
3321
Analogously, the specificity of an '':nth-child()'' or '':nth-last-child()'' selector
3327
3322
is the specificity of the pseudo class itself (counting as one pseudo-class selector)
3328
-
plus the specificity of its selector list argument (if any).
3329
-
<li>
3330
-
The specificity of a '':not()'' pseudo-class is replaced by
3331
-
the specificity of the most specific complex selector in its selector list argument.
3323
+
plus the specificity of
3324
+
the most specific complex selector in its selector list argument (if any).
3332
3325
<li>
3333
3326
The specificity of a '':where()'' pseudo-class is replaced by zero.
3334
3327
</ul>
@@ -3338,18 +3331,25 @@ Calculating a selector's specificity</h2>
3338
3331
<ul>
3339
3332
<li>
3340
3333
'':matches(em, #foo)'' has
3341
-
a specificity of (0,0,1)--like a tag selector--when matched against <code><em></code>,
3342
-
and a specificity of (1,0,0)--like an ID selector--when matched against <code><em id=foo></code>.
3334
+
a specificity of (1,0,0)--
3335
+
like an ID selector--
3336
+
when matched against any of
3337
+
<code><em></code>, <code><p id=foo></code>, or <code><em id=foo></code>.
3343
3338
<li>
3344
3339
''div:where(em, #foo#bar#baz)'' has
3345
-
a specificity of (0,0,1): only the ''div'' contributes to selector specificity.
3340
+
a specificity of (0,0,1):
3341
+
only the ''div'' outside the '':where()''
3342
+
contributes to selector specificity.
3346
3343
<li>
3347
3344
'':nth-child(even of li, .item)'' has
3348
-
a specificity of (0,1,1)--like a tag selector plus a pseudo-class--when matched against <code><li></code>,
3349
-
and a specificity of (0,2,0)--like a class selector plus a pseudo-class--when matched against <code><li class=item id=foo></code>.
3345
+
a specificity of (0,2,0)--
3346
+
like a class selector plus a pseudo-class--
3347
+
when matched against any of
3348
+
<code><li></code>, <code><ul class=item></code>, or <code><li class=item id=foo></code>.
3350
3349
<li>
3351
3350
'':not(em, #foo)'' has
3352
-
a specificity of (1,0,0)--like an ID selector--whenever it matches any element.
3351
+
a specificity of (1,0,0)--like an ID selector--
3352
+
whenever it matches any element.
3353
3353
</ul>
3354
3354
</div>
3355
3355
@@ -3380,17 +3380,16 @@ Calculating a selector's specificity</h2>
3380
3380
#x34y /* a=1 b=0 c=0 */
3381
3381
#s12:not(FOO) /* a=1 b=0 c=1 */
3382
3382
.foo :matches(.bar, #baz)
3383
-
/* Either a=1 b=1 c=0
3384
-
or a=0 b=2 c=0, depending
3385
-
on the element being matched. */
3383
+
/* a=1 b=1 c=0 */
3386
3384
</pre>
3387
3385
</div>
3388
3386
3389
3387
Note: Repeated occurrences of the
3390
3388
same simple selector are allowed and do increase specificity.
3391
3389
3392
3390
Note: The specificity of the styles
3393
-
specified in an HTML <code>style</code> attribute <a href="https://www.w3.org/TR/css-style-attr/#interpret">is described in CSS Style Attributes</a>. [[CSSSTYLEATTR]]
3391
+
specified in an HTML <code>style</code> attribute
3392
+
<a href="https://www.w3.org/TR/css-style-attr/#interpret">is described in CSS Style Attributes</a>. [[CSSSTYLEATTR]]
3394
3393
3395
3394
<h2 id="grammar" oldids="formal-syntax">
3396
3395
Grammar</h2>
@@ -3913,8 +3912,13 @@ Changes</h2>
3913
3912
Significant changes since the <a href="https://www.w3.org/TR/2018/WD-selectors-4-20180202/">2 February 2018 Working Draft</a>:
3914
3913
3915
3914
<ul>
3915
+
<li>Named the zero-specificity selector to '':where()''.
0 commit comments