It is worth noting that it ::selectionwas removed from the Selectors Level 3 specification and should be logically avoided while Pseudo-Elements Level 4 is supported by modern browsers. For this reason, you can observe strange problems in browsers that have implemented the Selectors Level 3 pseudo-element version.
7.3. Blank
This section intentionally left blank. (This section previously defined a pseudo-element ::selection.)
The MDN article is::selection further cited:
Although this pseudo-element was in CSS Selectors Level 3 projects, it was removed during the candidate recommendation phase, as it turned out that its behavior was undetermined, especially with nested elements, and interoperability was not achieved.
, , , .