::selection

A pseudo-element that styles the part of a document that has been highlighted by the user (usually by clicking and dragging with the mouse).

/* Usage Example */
::selection {
  /* Changes the default blue highlight color to your brand color */
  background: var(--brand-accent);
  color: white;
}
Limited availability Since 2020 84% global usage

This feature is not Baseline because it does not work in some of the most widely-used browsers.

1+
62+
1.1+
12+
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