::selection - CSS pseudo selector
Milap Patel
Technical Manager | Node.js | React | JavaScript | AWS Certified Cloud Practitioner | PHP | WordPress | Front-end | MongoDB | MySQL
You can change the background color and color of selected text by styling ::selection.
Styling this pseudo element is great for matching user-selected text to your sites color scheme.
You can style ::selection on individual elements. You can also style the entire page by dropping the bare pseudo-element in your stylesheet.
There are only three properties that ::selection will work with:
One of the most helpful uses for ::selection is turning off a text-shadow during selection.