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 h
All answers here are correct when it comes to the ::selection pseudo element, and how it works. However, the question does in fact specifically ask how to use it on text inputs.
The only way to do that is to apply the rule via a parent of the input (any parent for that matter):
.parent ::-webkit-selection, [contenteditable]::-webkit-selection {
background: #ffb7b7;
}
.parent ::-moz-selection, [contenteditable]::-moz-selection {
background: #ffb7b7;
}
.parent ::selection, [contenteditable]::selection {
background: #ffb7b7;
}
/* Aesthetics */
input, [contenteditable] {
border:1px solid black;
display:inline-block;
width: 150px;
height: 20px;
line-height: 20px;
padding: 3px;
}
Content Editable