@@ -3543,7 +3543,9 @@ Grammar</h2>
3543
3543
<dfn><pseudo-class-selector></dfn> = ':' <<ident-token>> |
3544
3544
':' <<function-token>> <<any-value>> ')'
3545
3545
3546
- <dfn><pseudo-element-selector></dfn> = ':' <<pseudo-class-selector>>
3546
+ <dfn><pseudo-element-selector></dfn> = ':' <<pseudo-class-selector>> | <<legacy-pseudo-element-selector>>
3547
+
3548
+ <dfn><legacy-pseudo-element-selector></dfn> = ':' [before | after | first-line | first-letter]
3547
3549
</pre>
3548
3550
3549
3551
In interpreting the above grammar,
@@ -3568,14 +3570,14 @@ Grammar</h2>
3568
3570
between two <<compound-selector>> s
3569
3571
if the <<combinator>> between them is omitted.
3570
3572
(This indicates the descendant combinator is being used.)
3571
- <li id="single-colon-pseudos">
3572
- The four <a href="https://www.w3.org/TR/CSS2/selectors.html#pseudo-element-selectors">Level 2</a> <a>pseudo-elements</a>
3573
- (''::before'' , ''::after'' , ''::first-line'' , and ''::first-letter'' )
3574
- may, for legacy reasons,
3575
- be represented using the <<pseudo-class-selector>> grammar,
3576
- with only a single ":" character at their start.
3577
3573
<li>
3578
3574
In <<id-selector>> , the <<hash-token>> ’s value must be an <a>identifier</a> .
3575
+ <li>
3576
+ The <<pseudo-class-selector>> production
3577
+ excludes the <<legacy-pseudo-element-selector>> production.
3578
+ (That is, '':before'' /etc must never be parsed as a pseudo-class,
3579
+ even if doing so would cause the selector to become valid
3580
+ due to, for example, other simple selectors following it.)
3579
3581
</ul>
3580
3582
3581
3583
Note: A selector is also subject to a variety of more specific syntactic constraints,
@@ -3594,6 +3596,13 @@ Grammar</h2>
3594
3596
and the <a>tree-abiding pseudo-elements</a>
3595
3597
are allowed after the ''::slotted()'' pseudo-element.)
3596
3598
3599
+ <p class=note id=single-colon-pseudos>
3600
+ The four <a href="https://www.w3.org/TR/CSS2/selectors.html#pseudo-element-selectors">Level 2</a> <a>pseudo-elements</a>
3601
+ (''::before'' , ''::after'' , ''::first-line'' , and ''::first-letter'' )
3602
+ may, for legacy reasons,
3603
+ be written with only a single ":" character at their front,
3604
+ making them resemble a <<pseudo-class-selector>> .
3605
+
3597
3606
<h3 id='forgiving-selector'>
3598
3607
<<forgiving-selector-list>> and <<forgiving-relative-selector-list>></h3>
3599
3608
@@ -4051,6 +4060,8 @@ Changes since the 7 May 2022 Working Draft</h3>
4051
4060
(<a href="https://github.com/w3c/csswg-drafts/issues/3760">Issue 3760</a> )
4052
4061
* Defined '':-webkit-autofill'' [=legacy selector alias=] .
4053
4062
(<a href="https://github.com/w3c/csswg-drafts/issues/7474">Issue 7474</a> )
4063
+ * Moved the legacy single-colon pseudo-element syntax into the grammar itself.
4064
+ (<a href="https://github.com/w3c/csswg-drafts/issues/8122">Issue 8122</a> )
4054
4065
4055
4066
<h3 id="changes-2018-11">
4056
4067
Changes since the 21 November 2018 Working Draft</h3>
0 commit comments