::target-text

A pseudo-element that allows you to style text that has been targeted via a URL fragment (the part after the # in a URL). This is often used for 'scrol-to-text' highlights.

Quick example

::target-text {
  /* Customizes the highlight color when the user arrives at this specific text via a link */
  background-color: var(--brand-highlight);
  color: black;
}

::target-text Browser Support

Newly available Since 2024 92% global usage

Since 2024 this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Works in all modern browsers. May need a fallback for older browsers.

89+
131+
18.2+
89+
ESC