I have an input field, and the color of the text in it is black. (I'm using jquery.placeholder) Let's say the text in there is "E-Mail"
When you click on this field, the black placeholding text dissapears (thanks to jquery.placeholder).
Any text inputted into this field, I want it to turn red, and when you deselect this field, I want it to stay red.
At the moment, the text saying "E-Mail" is black, and anything I type into is red, which is great, but as soon as i deselect, it goes back to black. Can anyone help me? I want the text to stay red, even after it's deselected. Here is my code
textarea:focus, input:focus {
color: #ff0000;
}
input, select, textarea{
color: #000;
}
To add color to an input, Use the following css code:
I always do input prompts, like this:
Of course, if your user fills in the field, changes focus and comes back to the field, the field will once again be cleared. If you do it like that, be sure that's what you want. You can make it a one time thing by setting a semaphore, like this:
Your <input> field then looks like this:
If you want the placeholder text to be red you need to target it specifically in CSS.
Write:
Change your second style to this:
At the moment, you are telling the form to change the text to
black
once the focus is off. The above remedies that.Also, it is a good idea to place the normal state styles ahead of the
:focus
and:hover
styles in your stylesheet. That helps prevent this problem. Soreplace:
with:
or
color: #ff0000;