Skip to content

Commit 103f7a1

Browse files
committed
[css-pseudo-4] Add ::target-text pseudo-element per WG resolution.
1 parent e1dc34d commit 103f7a1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

css-pseudo-4/Overview.bs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ Styling the ''::first-letter'' Pseudo-element</h4>
438438
Highlight Pseudo-elements</h2>
439439

440440
<h3 id="highlight-selectors">
441-
Selecting Highlighted Content: the ''::selection'', ''::inactive-selection'', ''::spelling-error'', and ''::grammar-error'' pseudo-elements</h3>
441+
Selecting Highlighted Content: the ''::selection'', ''::inactive-selection'', ''::target-text'', ''::spelling-error'', and ''::grammar-error'' pseudo-elements</h3>
442442

443443
The <dfn export lt="highlight pseudo-element">highlight pseudo-elements</dfn>
444444
represent portions of a document that have been given a particular status
@@ -467,6 +467,16 @@ Selecting Highlighted Content: the ''::selection'', ''::inactive-selection'', '
467467
whereas ''::inactive-selection'' applies to inactive selections
468468
(e.g. when the document window is inactive and therefore not receiving events).
469469

470+
<dt><dfn>::target-text</dfn>
471+
<dd>
472+
The ''::target-text'' pseudo-element represents text
473+
directly targetted by the document URL’s [=URL/fragment=], if any.
474+
475+
Note: When a [=URL fragment=] targets an element,
476+
the '':target'' pseudo-element can be used to select it,
477+
but ''::target-text'' does not match anything.
478+
It only matches text that is itself targetted by the [[=URL/fragment=]].
479+
470480
<dt><dfn>::spelling-error</dfn>
471481
<dd>
472482
The ''::spelling-error'' pseudo-element represents
@@ -547,11 +557,16 @@ Styling Highlights</h3>
547557
Note: Historically (and at the time of writing)
548558
only 'color' and 'background-color' have been interoperably supported.
549559

560+
<h3 id=highlight-ua-styles>
561+
Default UA Styles</h3>
562+
550563
The following addition is made to the default UA stylesheet:
551564
<pre><code class="lang-css">
552565
/* Represent default spelling/grammar error styling in an adjustable way */
553566
:root::spelling-error { text-decoration-line: spelling-error; }
554567
:root::grammar-error { text-decoration-line: grammar-error; }
568+
/* Highlight targetted text */
569+
:root::target-text { color: MarkText; background: Mark; }
555570
</code></pre>
556571

557572
<h3 id=highlight-bounds>
@@ -689,6 +704,7 @@ Backgrounds</h4>
689704
(i.e. just before step 8 in <a href="https://www.w3.org/TR/CSS22/zindex.html#painting-order">CSS2.2&sect;E.2</a>).
690705
<!-- Its outline, if any, is painted immediately over its background. -->
691706
The ''::selection'' overlay is drawn
707+
over the ''::target-text'' overlay which is drawn
692708
over the ''::spelling-error'' overlay
693709
which is drawn over the ''::grammar-error'' overlay.
694710

@@ -1006,6 +1022,7 @@ Changes</h2>
10061022
Changes since the <a href="https://www.w3.org/TR/2019/WD-css-pseudo-4-20190225/">25 February 2019 Working Draft</a> include:
10071023

10081024
<ul>
1025+
<li>Added ''::target-text'' pseudo-element.
10091026
<li>Included spaces between the first letter and its surrounding punctuation in ''::first-letter''.
10101027
(<a href="https://github.com/w3c/csswg-drafts/issues/5154">Issue 5154</a>)
10111028
<li>Adjust rules for inheritance of properties from ''::first-line''

0 commit comments

Comments
 (0)