← Chrome 160 reference · All APIs

v160 · cssom · enabled by default

CSSPseudoElement.selectorText

The read-only CSSPseudoElement.selectorText property returns the full, normalized CSS selector string for a pseudo-element — including any functional arguments such as ::view-transition-group(hero) or ::scroll-button(inline-end) — in a form that round-trips cleanly back into Element.pseudo(), CSSPseudoElement.pseudo(), getComputedStyle(), and Element.animate().

Limited availability — CSSPseudoElement.selectorText is Chrome/Chromium-only (base CSSPseudoElement is also Limited availability)

  • Chrome · 160 (desktop, Android, WebView)
  • Edge · Chromium-based (passes 4/4 WPT in 160.0.4408.0)
  • Firefox · No signal (base interface behind pref)
  • Safari · No signal (base interface unsupported)

The base css-object-model-csspseudoelement web-feature is Limited availability per webstatus.dev (Chrome/Edge 149; Firefox behind dom.css_pseudo_element.enabled; Safari unsupported). BCD api/CSSPseudoElement.json does not yet list selectorText (checked 2026-11-24).

at a glance

Shipped inChrome 160 (desktop, Android, Android WebView) — listed under “Enabled by default” in the milestone=160 listing and targeted for Chrome 160 in the ChromeStatus API record
Origin trial / flagNo origin trial, no user-facing chrome://flags entry. Blink runtime feature CSSPseudoElementSelectorText (depends on CSSPseudoElementInterface; currently status: "experimental" in runtime_enabled_features.json5; testable on earlier builds via --enable-blink-features=CSSPseudoElementSelectorText)
SpecificationCSS Pseudo-Elements Module Level 4 §7.1 CSSPseudoElement.selectorText (CSSWG PR #13169)
CSSWG issuesw3c/csswg-drafts#12161 (retrieving pseudo-element arguments); w3c/csswg-drafts#14528 (::scroll-button() direction serialization)
ExplainerCSSPseudoElement.selectorText explainer
Intentblink-dev Intent to Prototype; blink-dev Intent to Ship
Tracking bugissues.chromium.org/567978984
Web platform testswpt.fyi — css/css-pseudo/CSSPseudoElement-selectorText.html (WPT source)
ChromeStatus5071155760332800 — CSSPseudoElement.selectorText

why it exists

CSSPseudoElement.type returns only the base pseudo-element identifier without functional arguments — for example, "::view-transition-group" or "::scroll-button". For parameterized pseudo-elements, type cannot distinguish ::view-transition-group(hero) from ::view-transition-group(sidebar) or tell which ::scroll-button() direction received an event on event.pseudoTarget. Adding selectorText preserves type as a clean category check while exposing the exact normalized selector string (including escaped arguments) needed to disambiguate instances and call string-based APIs like getComputedStyle() and Element.animate().

Source: ChromeStatus motivation (5071155760332800); CSSPseudoElement.selectorText explainer; w3c/csswg-drafts#12161.

Syntax

WebIDL from CSS Pseudo-Elements Module Level 4 §7.1 (the selectorText attribute is the Chrome 160 addition; type, element, parent, and pseudo() are pre-existing members of CSSPseudoElement shown for interface context):

[Exposed=Window]
interface CSSPseudoElement {
  readonly attribute CSSOMString type;
  readonly attribute Element element;
  readonly attribute (Element or CSSPseudoElement) parent;
  readonly attribute CSSOMString selectorText;
  CSSPseudoElement? pseudo(CSSOMString type);
};

“The selectorText attribute is a string representing the full, normalized selector text used to select the pseudo-element. This includes the pseudo-element name and any arguments, serialized in a form that can round-trip. For example, "::after" for a ::after pseudo-element, or "::scroll-button(left)" for a ::scroll-button() pseudo-element with a left argument.”

This reference covers the two parts of the Chrome 160 contract: the CSSPseudoElement.selectorText property contract and its CSSOM normalization and serialization rules (including ::view-transition-* identifiers and ::scroll-button() directions).

Source: CSS Pseudo-Elements 4 §7.1 CSSPseudoElement.selectorText (fetched 2026-11-24); Blink css_pseudo_element.idl.

CSSPseudoElement.selectorText — inputs and outputs

Inputs. selectorText is a read-only getter on CSSPseudoElement instances and takes no arguments. Instances are obtained via element.pseudo(type), cssPseudoElement.pseudo(type), or event properties such as event.pseudoTarget.

Outputs. Returns a CSSOMString containing the canonical double-colon pseudo-element name in lowercase, followed by (argument) whenever the pseudo-element carries an argument. For a nested sub-pseudo-element (such as target.pseudo("::before").pseudo("::marker")), selectorText returns only its own pseudo-element selector ("::marker"), not a compound chain — walk pseudo.parent.selectorText ("::before") to inspect ancestors.

Comparison of CSSPseudoElement.type and CSSPseudoElement.selectorText across pseudo-element kinds
How the CSSPseudoElement was obtainedtypeselectorText
el.pseudo("::before") / el.pseudo(":before") / el.pseudo("::BEFORE")"::before""::before"
el.pseudo("::before").pseudo("::marker")"::marker""::marker" (own segment only)
el.pseudo("::scroll-button(left)")"::scroll-button""::scroll-button(left)"
el.pseudo("::scroll-button( inline-start )")"::scroll-button""::scroll-button(inline-start)"
Browser-created scroll button (e.g. event.pseudoTarget)"::scroll-button""::scroll-button(inline-start)" (logical direction)
pair.pseudo("::view-transition-old(header)")"::view-transition-old""::view-transition-old(header)"
Source: CSSPseudoElement.selectorText explainer; WPT CSSPseudoElement-selectorText.html; Blink css_pseudo_element.cc.

Serialization rules — normalization, escaping, and ::scroll-button()

In Chromium’s CSSPseudoElement::selectorText() implementation, serialization starts from the canonical lowercase double-colon tag name (::before, ::after, ::marker, ::backdrop, ::scroll-marker, ::scroll-button, ::view-transition, ::view-transition-group, ::view-transition-image-pair, ::view-transition-old, ::view-transition-new) and appends (<argument>) when an argument is present:

Source: Blink css_pseudo_element.cc; w3c/csswg-drafts#14528; CSSPseudoElement.selectorText explainer.

Errors, edge cases, and feature detection

Reading pseudo.selectorText never throws an exception. Because selectorText is a read-only attribute on CSSPseudoElement.prototype, assigning to it silently fails in sloppy mode and throws a TypeError in strict mode.

Source: Blink css_pseudo_element.cc (ConvertTypeToSupportedPseudoId & pseudo()); CSS Pseudo-Elements 4 §7.1.

Context and exposure

CSSPseudoElement and its selectorText attribute are exposed in Window contexts only ([Exposed=Window]; not available in Web Workers). No secure context, permission, or user activation is required. As verified by WPT CSSPseudoElement-selectorText.html, selectorText works identically on disconnected elements created with document.createElement("div") and on elements that do not currently generate a box for that pseudo-element.

Source: CSS Pseudo-Elements 4 §7.1; WPT CSSPseudoElement-selectorText.html.

Lifecycle and object identity

Per CSS Pseudo-Elements 4 §7.2 and Blink’s CSSPseudoElementsCacheData, repeated lookups for the same (originating element, pseudo_id, argument) return the same cached CSSPseudoElement object identity, so el.pseudo(p.selectorText) === p (or p.parent.pseudo(p.selectorText) === p for sub-pseudo-elements) holds across round trips. The serialized selectorText of a CSSPseudoElement instance is immutable over that object’s lifetime: as noted in CSS Pseudo-Elements 4, changing writing-mode does not rewrite a previously created physical ::scroll-button(left) object’s selectorText, even though it may resolve to a different flow-relative button at layout time.

Source: CSS Pseudo-Elements 4 §7.2; Blink css_pseudo_element.cc.

Examples

Interactive lab & disambiguating ::scroll-button() and ::view-transition-*

Live interactive lab comparing CSSPseudoElement.type and CSSPseudoElement.selectorText. Source: Chrome Platform Showcase — CSSPseudoElement.selectorText.
// 1. Disambiguate browser-created ::scroll-button() clicks and round-trip
//    selectorText into getComputedStyle() and element.animate().
carousel.addEventListener("click", (event) => {
  const pseudo = event.pseudoTarget;
  if (pseudo?.type !== "::scroll-button") return;

  // Browser-created scroll buttons serialize with logical directions:
  if (pseudo.selectorText === "::scroll-button(inline-end)") {
    const { opacity } = getComputedStyle(pseudo.element, pseudo.selectorText);
    pseudo.element.animate([{ opacity }, { opacity: 0.4 }, { opacity }], {
      duration: 240,
      pseudoElement: pseudo.selectorText,
    });
  }
});

// 2. Author-created scroll buttons preserve their coordinate space:
const physical = carousel.pseudo("::scroll-button(left)");
physical?.selectorText; // "::scroll-button(left)"

const logical = carousel.pseudo("::scroll-button( inline-start )");
logical?.selectorText;  // "::scroll-button(inline-start)"

// 3. Nested view-transition pseudo-elements return only their own segment:
const vt = document.documentElement.pseudo("::view-transition");
const group = vt?.pseudo("::view-transition-group(hero)");
const pair = group?.pseudo("::view-transition-image-pair(hero)");
const oldSnap = pair?.pseudo("::view-transition-old(hero)");
oldSnap?.type;          // "::view-transition-old"
oldSnap?.selectorText;  // "::view-transition-old(hero)"
oldSnap?.parent === pair; // true

Additional interactive demos on the Chrome Platform Showcase cover the pseudoTarget inspector, round-tripping into string APIs, view transition disambiguation, and scroll-button directions.

Source: CSSPseudoElement.selectorText explainer; Blink css_pseudo_element.cc.

Feature-detecting CSSPseudoElement.selectorText

function supportsPseudoSelectorText() {
  return (
    typeof CSSPseudoElement !== "undefined" &&
    "selectorText" in CSSPseudoElement.prototype
  );
}

function describePseudo(pseudo) {
  if (!pseudo) return null;
  // Falls back to base type on Chrome 149-159 where selectorText is absent
  return supportsPseudoSelectorText() ? pseudo.selectorText : pseudo.type;
}
Source: CSS Pseudo-Elements 4 §7.1; BCD api/CSSPseudoElement.json.

Browser compatibility

Support for CSSPseudoElement.selectorText. BCD does not yet include a selectorText entry; interim status comes from ChromeStatus, wpt.fyi, and vendor standards positions (checked 2026-11-24). The base-interface column is from BCD.
BrowserselectorTextEvidence / notesBase CSSPseudoElement (BCD)
Chrome (desktop, Android, WebView)160Targeted for Chrome 160 across desktop, Android, and WebView per ChromeStatus 5071155760332800 (runtime flag CSSPseudoElementSelectorText)149
Edge160 (dev)Chromium-based; wpt.fyi Edge 160.0.4408.0 passes 4/4 subtests (2026-11-24)149 (mirror)
FirefoxNo supportMozilla standards position #1489: No signal75 (behind pref dom.css_pseudo_element.enabled)
SafariNo supportWebKit standards position #744: No signalNo support
Source: BCD api/CSSPseudoElement.json; ChromeStatus API record; wpt.fyi results; webstatus.dev css-object-model-csspseudoelement.

Security and privacy

CSSPseudoElement.selectorText is a read-only string serializer for pseudo-element references the script already holds. It exposes only CSS pseudo-element type names and selector arguments (such as author-defined view-transition-name identifiers or standard logical ::scroll-button() direction keywords). It introduces no new storage, network capability, permission prompt, or cross-origin data exposure. ChromeStatus 5071155760332800 records no security risks, and CSS Pseudo-Elements 4 Security & Privacy Considerations raise no additional concerns for selectorText.

Source: ChromeStatus 5071155760332800; CSS Pseudo-Elements 4 Security Considerations.

Specifications

see also