How to change the color of content in HTML input type text while entering some value. And also the cursor color when it has focus.
Changing the colour when entering content is easy:
input:focus { color: yellow }
not supported by IE7 and lower. Compatibility table here.
Changing the cursor colour specifically is impossible as far as I know. It will usually take on the text content's colour which should be fine in most cases.
Use color
to specify the text color. Use caret-color
to specify the caret's color.
HTML
<input class="examples" />
<textarea class="examples"></textarea>
CSS
.examples {
color: gray;
caret-color: red;
}
Use modern CSS!
input {
caret-color : red;
}
input:focus {
color : yellow;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With