Changing the text selection color using CSS?
Solution 1:
I have wandered upon this problem before and it turns out:
::selection (or whatever selection you might use)
does not work on an break line tag (br).. remove them and use margins instead. =) Here is an fiddle to demonstrate: Example
Solution 2:
Try This :
<style>
*::selection {
background: #cc0000;
color: #ffffff;
}
*::-moz-selection {
background: #cc0000;
color: #ffffff;
}
*::-webkit-selection {
background: #cc0000;
color: #ffffff;
}
</style>
See for More Detail
Solution 3:
/*** Works on common browsers ***/
::selection {
background-color: #352e7e;
color: #fff;
}
/*** Mozilla based browsers ***/
::-moz-selection {
background-color: #352e7e;
color: #fff;
}
/***For Other Browsers ***/
::-o-selection {
background-color: #352e7e;
color: #fff;
}
::-ms-selection {
background-color: #352e7e;
color: #fff;
}
/*** For Webkit ***/
::-webkit-selection {
background-color: #352e7e;
color: #fff;
}