How to change the color of selected text?

Please left-click and drag this text (check it). The color you see is blue, would I like to change this color to dark green using Javascript or HTML / CSS?

+3
source share
2 answers

Browser support is limited.

::selection {
        background: #ffb7b7; /* Safari */
        }
::-moz-selection {
        background: #ffb7b7; /* Firefox */
}

Example .

Further reading .

+9
source

http://snipplr.com/view/4285/change-color-of-selected-text/

Its CSS3 and only Safari and Firefox support this, and both in different ways.

+2
source

Source: https://habr.com/ru/post/1794351/


All Articles