I'm trying to change the selection color for an entire web page using a css variable:
html {
--my-var: red;
}
::selection {
background-color: var(--my-var);
}
<p>a b c</p>
<div>
<p>x y z</p>
</div>
See Question&Answers more detail:os