Saturday, November 29, 2014

How to change the color of a placeholder of input box

Add this to your CSS to change the color of place holder.
::-webkit-input-placeholder {
   color: red;
}
 
:-moz-placeholder {
   color: red;
}
That would be nice, but the problem is that when a browser doesn’t understand a selector, it invalidates the entire line of selectors (except IE 7)
For old browsers You can use Javascript as below :
<input name="location" type="text" value="Location"
onblur="this.value=!this.value?'Location':this.value;" onclick="this.value='';" />

No comments:

Post a Comment