The selection pseudo-element

The selection pseudo-element allows you to set a color and background of a selected text.

Syntax

cssselector::selection {
  
}

Example

Select the text and you will see that it will be red on a black background:

html<div id="elem">
  Lorem ipsum dolor sit amet.
</div>
css#elem::selection {
  color: red;
  background-color: black;
}

Результат:

See also