::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.

/* Usage 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;
}
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.

89+
131+
18.2+
89+
Kinsta

Your first month is free

Managed WordPress hosting for faster sites.

Learn more

New CSS drops.

Join 600+ readers who've survived clearfix hacks.

ESC