::selection {
    /* ... */
}
<p>
    Drag your mouse to select some of the text in this paragraph
    and see how the styling changes for the selected portion.
</p>
p::selection {
    background-color: yellow;
    color: red;
}
Rendered Output Try dragging your mouse to select some text!
<p>
    Drag your mouse to select some of the text in this paragraph
    and see how the styling changes for the selected portion.
</p>
p::selection {
    background-color: yellow;
    color: red;
    text-shadow: 2px 2px 1px black;
}
Rendered Output Try dragging your mouse to select some text!

Last updated:

See more details on caniuse.com.