Changing the Color of Selection with CSS

Ole Ersoy
1 min readApr 24, 2020
Image by Gerd Altmann from Pixabay

Scenario

When the text is selected we want the text color to be red and the background to be yellow .

Approach

::selection {
color: red;
background: yellow;
}

--

--