Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input cursor color

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.

like image 949
eomeroff Avatar asked Apr 30 '10 16:04

eomeroff


3 Answers

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.

like image 119
Pekka Avatar answered Oct 07 '22 18:10

Pekka


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;
}
like image 28
sealocal Avatar answered Oct 07 '22 19:10

sealocal


Use modern CSS!

input {
    caret-color : red;
}
input:focus {
    color : yellow;
}
like image 37
Gibolt Avatar answered Oct 07 '22 20:10

Gibolt