Changing the highlight color when selecting text in an HTML text input
I've been looking for this throughout the web and can't even find anyone else even asking this, let alone a solution...
Is there a way to change the color of the highlight area within a text input when text is selected? Not the highlight border or the background, but the portion that appears around the text when you have the text actually selected.
If you are looking for this:
Here is the link:
http://css-tricks.com/overriding-the-default-text-selection-color-with-css/
this is the code.
/*** 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;
}
I realise this is an old question but for anyone who does come across it this can be done using contenteditable
as shown in this JSFiddle.
Kudos to Alex who mentioned this in the comments (I didn't see that until now!)