::selection - CSS Selector
Summary of characteristics of the ::selection selector
::selection pseudo-element - Description.
The pseudo-element ::selection targets the text, or any element, when it is selected.
Quite a few properties are taken into account when applied to the selector ::selection. Here are the main ones:
- Definition of foreground and background colors:
colorandbackground-color. - Choice of the mouse pointer shape and the text cursor color:
cursorandcaret-color. - The properties that define the stripe stroke format:
stroke-color,
fill-color, and
stroke-width.
::selection pseudo-element - Examples of use.
Simple example: changing the colors of the selected text.
This example only plays with foreground and background colors. It should work on all browsers.
The selection in this paragraph appears in inverted colors (white text on a black background).
No longer show the selection.
It’s easy to give the impression that selection is disabled: just apply a transparent background color to the selector ::selection.
But be careful, even though the selection no longer shows on the screen, it is still actually happening.
To truly disable the ability to select, refer to the user-select property.

This example also shows that ::selection applies to input areas like textarea. You can check in this area that the
selection is correctly made by deleting the text after selection.
The selection in this paragraph isn't visible.
Change the look of the selected element or text.
A specific style has been applied to the selection in this paragraph: it is crossed out.
Be careful, not all browsers apply these properties to the selector ::selection
Select all or part of the text to see the result.
Make a text blurry when it's selected.
Making text blurry is possible, but forget about the filter property, it can't be used with ::selection.
You just need to apply a shadow to the text and make the text transparent (the shadow won't be affected).
This text gets blurry when it's selected.
::selection pseudo-element - Browser compatibility.
The pseudo-element ::selection is recognized by current browsers, but the examples above show that not all normally supported properties work,
depending on the browser used.
::selection pseudo-element targeting the selected text or elements.::selectionpseudo-element
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Samsung Internet

Firefox

Safari

Safari sur IOS

Chrome

Opéra

Edge

Chrome pour Androïd

Firefox pour Androïd

Androïd Brower

KaiOS Browser

Opéra mini
::selection pseudo-element - Historic.
-
CSS Pseudo-Elements Module Level 4
Regarding::selectionIntroduction of a new pseudo-element selector:::selection.January 15, 2015Working Draft.
See also...
The pseudo-elements are described in the specification "CSS Pseudo-Elements Module ". There are many of them, but here are the ones that deal with targeting the selected text.





