0

How can we change the color of placeholder of selected input fields.

input[type="text"].smInput{
color: #333;
}
  • Possible duplicate: [Change an input's HTML5 placeholder color with CSS](http://stackoverflow.com/q/2610497/1492578) – John Bupit Jun 30 '14 at 09:08
  • Please use google like this before asking question `site:stackoverflow.com How can we change the color of placeholder` – Gildas.Tambo Jun 30 '14 at 09:14

3 Answers3

1

The placeholder text is exposed to CSS as a pseudo-element, so use the pseudo-element selector. It hasn't yet been standardised, so you need to repeat the selector for the layout-engines that support it:

input[type=text].smInput::-moz-placeholder,
input[type=text].smInput:-ms-input-placeholder, /* IE uses a pseudo-class rather than pseudo-element */
input[type=text].smInput::-webkit-input-placeholder, {
    color: #333;
}

Source:

Dai
  • 141,631
  • 28
  • 261
  • 374
1
input:-moz-placeholder, textarea:-moz-placeholder{
    color: #222;
}
input::-webkit-input-placeholder, textarea::-moz-placeholder{
    color: #222;
}
0
input[type="text"].smInput:-moz-placeholder, textarea:-moz-placeholder{
    color: #222;
}
input[type="text"].smInput::-webkit-input-placeholder, textarea::-moz-placeholder{
    color: #222;
}