← Chrome 158 reference

v158 · css · enabled by default

CSS Custom Highlight Universal Selector ::highlight(*)

Limited availability — the * argument is not Baseline (parent ::highlight() is Baseline Newly available)

  • Chrome · 158
  • Edge · Chromium-based; no BCD entry yet
  • Firefox · Nightly only (partial, per WPT)
  • Safari · WebKit trunk only; no shipped version known

There is no web-feature id for the * argument yet: the ChromeStatus record lists its web feature as “Missing feature”, and BCD css/selectors/highlight.json has no subfeature for it (both checked 2026-11-22). The parent Custom highlights web-feature is Baseline Newly available since 2026-03-24 per webstatus.dev — that covers ::highlight(<custom-ident>) only. Treat ::highlight(*) as a Chromium-first enhancement and keep a per-name fallback (see invalid selectors and fallbacks).

::highlight(*) is a universal argument for the ::highlight() pseudo-element: it matches the highlight pseudo-elements of every custom highlight registered in CSS.highlights, whatever its name. The * argument contributes zero specificity, so its declarations act as a shared base style, and any rule that names a specific highlight overrides it property by property through the normal cascade.

at a glance

Shipped inChrome 158 (desktop, Android, Android WebView), enabled by default — filed under “Enabled by default” in the milestone=158 listing; Chrome 158 stable date 2026-11-17 per the ChromeStatus channel schedule
Origin trial / flagNo origin trial, no user-facing flag. Blink runtime feature CSSCustomHighlightUniversalSelector has status stable in runtime_enabled_features.json5 (checked 2026-11-22)
SpecificationCSS Pseudo-Elements Level 4 §3.1 — ::highlight(<highlight-name-selector>) (editor’s draft, Working Draft maturity)
CSSWG decisionw3c/csswg-drafts#9091 — “RESOLVED: Add * to highlight pseudo” and “RESOLVED: Specificity of * in highlight pseudo is 0” (2025-04-02); spec text landed in w3c/csswg-drafts#14301 (merged 2026-09-29)
IntentsIntent to Prototype; Intent to Ship (2026-10-14, three LGTMs)
Tracking bugissues.chromium.org/408003366
Web platform testscss/css-highlight-api/custom-highlight-universal-* (parsing, escaped star, painting, inheritance)
ChromeStatus5174965228929024 — CSS Custom Highlight Universal Selector ::highlight(*)

why it exists

Before Chrome 158, every registered highlight name needed its own rule. A page with spelling, grammar and search highlights that all wanted the same underline thickness had to repeat it three times, and a highlight registered later by another script got no styling at all — custom highlights have no UA default style, so an unstyled custom highlight is invisible. The ChromeStatus motivation: “Styling shared properties across custom highlights requires repeating the same declarations for every registered name.” In the Intent to Ship thread, the feature owner cited developer demand, including the MDN ::highlight() example that repeats text-decoration per name.

Source: ChromeStatus motivation; blink-dev Intent to Ship thread; CSS Custom Highlight API §4.2.2 Default Styles (no UA default for custom highlights).

Syntax

Grammar from CSS Pseudo-Elements Level 4, quoted verbatim (fetched 2026-11-22):

::highlight(<highlight-name-selector>)

<highlight-name-selector> = '*' | <custom-ident>

“A <custom-ident> argument selects the single custom highlight whose custom highlight name is that identifier. The * argument selects every custom highlight, regardless of its custom highlight name.”

“The specificity of a ::highlight() selector with a <custom-ident> argument is equivalent to a type selector. The specificity of a ::highlight() selector with a * argument is zero.”

Typical forms of ::highlight(*):

::highlight(*)          { /* every element, every custom highlight */ }
:root::highlight(*)     { /* recommended document-wide base; inherited downwards */ }
article::highlight(*)   { /* every custom highlight inside <article> elements */ }

This page documents three pieces of the change: the * argument and what it matches, the zero-specificity cascade with named rules, and inheritance of the universal base through the element tree. Supporting sections cover invalid selectors and fallbacks, context and applicable properties, and painting and lifecycle.

Source: css-pseudo-4 §3.1 ::highlight(); CSSWG resolution in #9091.

The * argument — inputs and what it matches

Input. ::highlight(*) takes exactly one token, an unescaped * (a <delim-token>, written '*' in the grammar). It is the only alternative to a single <custom-ident>; there is no namespace, list, or pattern form. It may follow any compound selector that names the originating element (div::highlight(*), :root::highlight(*)), or stand alone, in which case the originating element is the implied universal type selector, exactly as for ::selection.

Accepted and rejected arguments (from the WPT parsing test)
SelectorValid?Meaning
::highlight(*)ValidEvery custom highlight, on every element
div::highlight(*), :root::highlight(*)ValidEvery custom highlight, originating element restricted by the compound
::highlight(foo)ValidOnly the highlight registered as foo (unchanged pre-158 behaviour)
::highlight(\*)ValidAn escaped star is a <custom-ident>: it selects only a highlight registered under the literal name "*", and has type-selector specificity
::highlight(), ::highlight(* foo), ::highlight(*.class), ::highlight(foo*), ::highlight(**)InvalidSelector fails to parse; the whole style rule is dropped

Output. For every element matched by the compound selector, the declarations apply to that element’s highlight pseudo-element for each registered custom highlight name. They do not merge highlights into one overlay: each name is still cascaded and painted independently, so two overlapping highlights that both pick up a semi-transparent background-color from ::highlight(*) paint that background twice where they overlap. A highlight that has no named rule at all is painted with the ::highlight(*) values alone (WPT no-named-rule-001). ::highlight(*) matches custom highlights only — it does not match ::selection, ::target-text, ::search-text, ::spelling-error or ::grammar-error.

Source: css-pseudo-4 §3.1; WPT custom-highlight-universal-parsing-and-computed-style.html; WPT custom-highlight-universal-escaped-star.html; WPT custom-highlight-universal-no-named-rule-001.html; CSS Custom Highlight API §4.2.4 Painting.

Errors: invalid selectors, older browsers and fallbacks

CSS has no exception path for a selector; the failure mode of ::highlight(*) is parse failure. A malformed argument (see the table above) — or any ::highlight(*) in an engine that predates the feature — makes the selector invalid, and an invalid selector invalidates the whole style rule, including every other selector in the same comma-separated list. Verified in headless Chrome 153 (pre-158) on 2026-11-22: CSSStyleSheet.insertRule("::highlight(*){…}") throws SyntaxError, while ::highlight(\*) parses.

Consequences you must design for:

Source: Selectors Level 4 §3.9 Invalid Selectors and Error Handling; WPT parsing test (invalid forms); CSS Conditional 4 — selector() in @supports; WebKit bug 323469.

Zero specificity and the per-property cascade

The specificity of ::highlight(*) is (0,0,0) for the pseudo-element part, while ::highlight(foo) counts like a type selector, (0,0,1). Specificity of the originating-element compound is added as usual: div::highlight(*) is (0,0,1) and div::highlight(foo) is (0,0,2).

Algorithm. For each element and each registered highlight name N, the cascade for that element’s ::highlight(N) collects the declarations of every rule whose selector matches it — both …::highlight(N) and …::highlight(*) rules — and resolves each property separately by origin, layer, specificity and then source order. So:

Resolved style for highlight foo given ::highlight(*) { color: red; background-color: yellow } and ::highlight(foo) { color: blue }
PropertyWinning ruleValue
color::highlight(foo) (higher specificity)blue
background-color::highlight(*) (only declaration)yellow
Source: css-pseudo-4 §3.1 specificity text; css-pseudo-4 §3.5 Cascading and Per-Element Highlight Styles; WPT painting-001, painting-002, painting-003.

Inheritance of the universal base

Highlight pseudo-elements inherit through the originating element tree: when a supported property gets no value from the cascade (or inherit/unset), its value comes from the same-named highlight pseudo-element on the parent element, “regardless of whether that property is an inherited property.” Because ::highlight(*) contributes to every name’s cascade on the elements it matches, a :root::highlight(*) base reaches a named highlight on any descendant, through any number of elements that have no highlight rules (WPT inheritance-001, deep-chain-001). If a parent has both a universal and a named rule, the parent’s own cascade decides first — the child inherits the named value (WPT inheritance-computed).

Pitfall — prefer :root::highlight(*). An unqualified ::highlight(*) means *::highlight(*): it matches on every element, so on a descendant it is a specified value that beats a value the descendant would otherwise have inherited from an ancestor’s named rule. Given p::highlight(foo) { color: blue } and ::highlight(*) { color: red }, text of foo inside an <em> in that paragraph is red. This is the same trap the spec describes for ::selection versus :root::selection; with :root::highlight(*) the base is inherited instead, and the paragraph’s blue reaches the <em>.

Source: css-pseudo-4 §3.5 (inheritance rule and the :root::selection example); WPT inheritance-001; WPT deep-chain-001; WPT inheritance-computed.

Context: where it applies and which properties work

::highlight(*) is a selector, usable in any author style sheet (<style>, <link>, constructed CSSStyleSheet, shadow-tree style sheets). It needs no permission, secure context or JavaScript; only the highlights themselves are created from script via CSS.highlights.set(name, new Highlight(...ranges)). The originating element is whatever the compound before ::highlight(*) selects; without one it is every element.

Only the restricted highlight property set applies, exactly as for named highlights: color, background-color, text-decoration and its longhands (including text-underline-position, text-underline-offset), text-shadow, stroke-color, fill-color, stroke-width, and custom properties. Other properties (for example background-image, font-weight) are ignored. The spec notes that historically only color and background-color have been interoperable.

Source: css-pseudo-4 §3.2 Styling Highlights; CSS Custom Highlight API §3 highlight registry.

Painting and lifecycle

::highlight(*) is matched by name at style time, not bound to the names registered when the style sheet loaded: a highlight added to CSS.highlights later is styled by the existing universal rule on the next rendering update, and a deleted one stops painting. Registry additions/removals, range changes and priority changes trigger an asynchronous repaint — no API call blocks on it. Each custom highlight name paints its own overlay, stacked by Highlight.priority (ties: most recently registered on top), all below ::selection, ::target-text, ::spelling-error and ::grammar-error. A single Highlight registered under two names is painted twice, so a universal background applies twice to it. Removing or disabling the universal rule (e.g. removing a constructed sheet from document.adoptedStyleSheets) restyles all highlights at once.

Source: CSS Custom Highlight API §5.1 Repaints; §4.2.5 Priority of Overlapping Highlights; §3 note on multiple names per highlight; css-pseudo-4 §3.6 Painting the Highlight.

Examples

Live example from the Chrome Platform Showcase (universal-base-style concept, HTTP 200 verified 2026-11-22; it probes support with insertRule and shows the per-name fallback in pre-158 engines).Source: chrome-platform-showcase — ::highlight(*)

A complete page: three highlights, one shared ::highlight(*) base, named rules for what differs, and a fallback for engines without *:

<p id="text">Teh quick brown fox jump over the lazy dog.</p>

<style>
  /* Shared base for every custom highlight (Chrome 158+). */
  :root::highlight(*) {
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
  }
  /* Named rules override per property (specificity 0,0,1 beats 0,0,0). */
  ::highlight(spelling) { text-decoration-color: red; text-decoration-style: wavy; }
  ::highlight(grammar)  { text-decoration-color: blue; }
  ::highlight(search)   { background-color: yellow; color: black; }

  /* Fallback: older engines reject ::highlight(*) entirely. */
  @supports not selector(::highlight(*)) {
    ::highlight(spelling) { text-decoration-line: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
    ::highlight(grammar)  { text-decoration-line: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
    ::highlight(search)   { text-decoration-line: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
  }
</style>

<script>
  const t = document.getElementById("text").firstChild;
  const at = (start, end) => {
    const r = new Range();
    r.setStart(t, start);
    r.setEnd(t, end);
    return r;
  };
  CSS.highlights.set("spelling", new Highlight(at(0, 3)));    // "Teh"
  CSS.highlights.set("grammar", new Highlight(at(20, 24)));   // "jump"
  CSS.highlights.set("search", new Highlight(at(16, 19)));    // "fox"
</script>
Source: css-pseudo-4 §3.1; CSS Custom Highlight API — creating and registering highlights.

Base style plus named override

Mirrors WPT painting-001: highlight foo paints blue text on yellow — color from the named rule, background-color from ::highlight(*). Swapping the two rules’ order changes nothing (painting-002).

::highlight(*)   { background-color: yellow; color: red; }
::highlight(foo) { color: blue; }

/* In script: */
const r = new Range();
r.setStart(document.body, 0);
r.setEnd(document.body, 2);
CSS.highlights.set("foo", new Highlight(r));

getComputedStyle(document.body, "::highlight(foo)").color;           // "rgb(0, 0, 255)"
getComputedStyle(document.body, "::highlight(foo)").backgroundColor; // "rgb(255, 255, 0)"
Source: WPT painting-001; WPT computed-style assertions.

Document-wide base inherited by descendants

Mirrors WPT deep-chain-001: the pink background set once on :root reaches the foo highlight inside nested elements that have no highlight rules, while the span’s own named rule supplies the colour.

<style>
  :root::highlight(*)  { background-color: pink; }
  span::highlight(foo) { color: green; }
</style>
<div><div><span id="target">One two three</span></div></div>
<script>
  const text = document.getElementById("target").firstChild;
  const r = new Range();
  r.setStart(text, 0);
  r.setEnd(text, 8);
  CSS.highlights.set("foo", new Highlight(r)); // "One two " paints green on pink
</script>
Source: WPT deep-chain-001; css-pseudo-4 §3.5.

Feature detection from script

const supportsUniversal = CSS.supports("selector(::highlight(*))");

const sheet = new CSSStyleSheet();
try {
  sheet.insertRule(":root::highlight(*) { text-decoration-line: underline; }");
} catch (e) {
  // SyntaxError in engines without ::highlight(*): fall back to one rule per name.
  for (const name of CSS.highlights.keys()) {
    sheet.insertRule(`::highlight(${CSS.escape(name)}) { text-decoration-line: underline; }`);
  }
}
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];

The fallback branch only styles names registered before it runs; that is exactly the gap ::highlight(*) closes.

Source: CSS Conditional 4 selector(); CSSOM insertRule() (throws SyntaxError on an unparsable rule); showcase universal-base-style uses the same probe.

Browser compatibility

Support for the * argument of ::highlight(). BCD has no entry for it yet, so implementation data comes from ChromeStatus, engine bugs and wpt.fyi (checked 2026-11-22). The parent column is from BCD.
Browser::highlight(*)Evidence / notesParent ::highlight(<custom-ident>) (BCD)
Chrome (desktop, Android), Android WebView158Enabled by default per ChromeStatus; wpt.fyi Chrome 160 canary passes every custom-highlight-universal test105
EdgeUnknown
(no BCD entry)
The wpt.fyi Edge 158.0.4370.33 run passes parsing and painting tests but 1 of 2 inheritance-computed subtests105 (mirror)
FirefoxNo releaseMozilla position: positive. Firefox Nightly 163.0a1 on wpt.fyi passes parsing and painting-001/002/003 but fails the inheritance and deep-chain tests — partial, unreleased149 (140–148 partial)
SafariNo releaseWebKit position: support; implemented in WebKit trunk (bug 323469, fixed 2026-09-11, 320952@main). The wpt.fyi Safari 27.2 stable run fails the painting tests17.2
Source: BCD css/selectors/highlight.json (no * subfeature); wpt.fyi custom-highlight-universal results; ChromeStatus API record; webstatus.dev Custom highlights.

Security and privacy

::highlight(*) adds a selector argument and no new data source, storage, network request or permission. It only styles ranges the page itself registered in CSS.highlights, and only with the paint-only highlight properties, so it cannot change layout. It does not match ::spelling-error or ::grammar-error, the highlights whose styling the spec flags as able to leak a user’s dictionary contents. The CSS Custom Highlight API states it is “not thought to introduce any new security concern” or privacy concern; css-pseudo-4 records no new privacy considerations. Chromium’s security and privacy reviews for this entry are listed as “Pending” in the ChromeStatus record (checked 2026-11-22).

Source: CSS Custom Highlight API Appendix A (privacy) and Appendix B (security); css-pseudo-4 §3.7 Security Considerations for Highlighting; css-pseudo-4 Privacy Considerations; ChromeStatus review status.

Specifications

see also