Skip to content

Commit

Permalink
[css-pseudo-4] Add ::target-text pseudo-element per WG resolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasai committed Oct 13, 2020
1 parent e1dc34d commit 103f7a1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion css-pseudo-4/Overview.bs
Expand Up @@ -438,7 +438,7 @@ Styling the ''::first-letter'' Pseudo-element</h4>
Highlight Pseudo-elements</h2>

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

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

<dt><dfn>::target-text</dfn>
<dd>
The ''::target-text'' pseudo-element represents text
directly targetted by the document URL’s [=URL/fragment=], if any.

Note: When a [=URL fragment=] targets an element,
the '':target'' pseudo-element can be used to select it,
but ''::target-text'' does not match anything.
It only matches text that is itself targetted by the [[=URL/fragment=]].

<dt><dfn>::spelling-error</dfn>
<dd>
The ''::spelling-error'' pseudo-element represents
Expand Down Expand Up @@ -547,11 +557,16 @@ Styling Highlights</h3>
Note: Historically (and at the time of writing)
only 'color' and 'background-color' have been interoperably supported.

<h3 id=highlight-ua-styles>
Default UA Styles</h3>

The following addition is made to the default UA stylesheet:
<pre><code class="lang-css">
/* Represent default spelling/grammar error styling in an adjustable way */
:root::spelling-error { text-decoration-line: spelling-error; }
:root::grammar-error { text-decoration-line: grammar-error; }
/* Highlight targetted text */
:root::target-text { color: MarkText; background: Mark; }
</code></pre>

<h3 id=highlight-bounds>
Expand Down Expand Up @@ -689,6 +704,7 @@ Backgrounds</h4>
(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>).
<!-- Its outline, if any, is painted immediately over its background. -->
The ''::selection'' overlay is drawn
over the ''::target-text'' overlay which is drawn
over the ''::spelling-error'' overlay
which is drawn over the ''::grammar-error'' overlay.

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

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

0 comments on commit 103f7a1

Please sign in to comment.