user3788405
user3788405

Reputation:

How can we change the color of placeholder?

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

input[type="text"].smInput{
color: #333;
}

Upvotes: 0

Views: 75

Answers (3)

user3796926
user3796926

Reputation:

input:-moz-placeholder, textarea:-moz-placeholder{
    color: #222;
}
input::-webkit-input-placeholder, textarea::-moz-placeholder{
    color: #222;
}

Upvotes: 1

Dai
Dai

Reputation: 155618

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:

Upvotes: 1

user3789621
user3789621

Reputation:

input[type="text"].smInput:-moz-placeholder, textarea:-moz-placeholder{
    color: #222;
}
input[type="text"].smInput::-webkit-input-placeholder, textarea::-moz-placeholder{
    color: #222;
}

Upvotes: 0

Related Questions