CSS ::selection Selector

The ::selection CSS pseudo-element applies styles to the portion of a document that has been highlighted by the user (such as with the mouse).

The ::selection selector matches the portion of an element that is selected by a user.Only a few CSS properties can be applied to the ::selection selector: color, background, cursor, and outline.

Example -