Custom CSS selection styling

The ::selection CSS pseudo-element allows you to apply styles to your text when it’s highlighted (such as clicking and dragging the mouse across text).

p::selection {
  background: blue;
  color: white;
}

It is important to note that the styles applied using the ::selection pseudo-element will only be applied to the selected text and not to the rest of the page.