::selection

The ::selection CSS pseudo-element applies styles to the part of a document that has been highlighted by the user. The most common use of this pseudo-element is to change the default blue color of highlighted text:

::selection {
    color: var(--color-background);
    background-color: var(--color-foreground);
}

In the example above the text- and background-color are inverted when text is highlighted.