Search code examples
csswordpresselementor

Does Firefox still need "::moz-selection" to change background text colour in wordpress?


Is ::moz-selection still required to change the text selection colour for Firefox? I've read a few articles who give the code below in order to change the text selection colour in my wordpress website.

/* MP highlight text red */
 
/* For FireFox */
**::-moz-selection** {
background-color: #50BAEE;
color: #fff;
}
/* For everyone else */
::selection {
background-color: #E53333;
color: #fff;

}

I simulated the code above on browserling.com for Firefox. The colour selection was RED (not blue) in the browser.

FIREFOX TEST RESULTS: https://browserling.com/b/941baebc

Do I still need to use ::moz-selection ?


Solution

  • ::selection and ::-moz-selection are CSS psuedo-elements, which means their behavior depends on the browsers themselves independently of Wordpress, (unless Wordpress is somehow mangling your input files, but I have never heard of them doing such a thing.)

    You can read more about them on this page, which contains the following information in the Syntax section:

    /* Legacy Firefox syntax (version 61 and below) */
    ::-moz-selection
    
    ::selection
    

    So whether you need ::-moz-selection depends on how much you care about what users of Firefox version 61 and below see. You can see more information about browser support and usage numbers here as well.