coderef

::selectionLimited availability

The ::selection CSS pseudo-element selects text a user has highlighted.

Not yet supported in all major browsers — check the table and provide a fallback.

Browser support

DesktopChrome
1+Supportedsince Dec 11, 2008
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–61Not supported
62+Supportedsince Sep 5, 2018
Current: 157
Safari
1–1Not supported
1.1+Supportedsince Oct 24, 2003
Current: 27
MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155
Firefox Android
4–61Not supported
62+Supportedsince Sep 5, 2018
Current: 157
Safari iOS
✕Not supportedup to 27
Current: 27

How to use

Not supported in Safari iOS. Use feature detection below and provide a fallback (or a polyfill) for those browsers.

Example

Full syntax and examples are on MDN: ::selection.

Feature detection

CSS · check before using
@supports selector(::selection) {
  /* styles that use ::selection */
}

/* or in JavaScript */
if (CSS.supports("selector(::selection)")) {
  // use it
}