Chrome v4 supports the placeholder attribute on input[type=text] elements (others probably do too).
However, the following CSS doesn’t do anything to the placeholder’s value:
input[placeholder], [placeholder], *[placeholder] {
color: red !important;
}
<input type="text" placeholder="Value">
Value will still remain grey instead of red.
Is there a way to change the color of the placeholder text?
Implementation
There are three different implementations: pseudo-elements, pseudo-classes, and nothing.
::-webkit-input-placeholder. [Ref]:-moz-placeholder(one colon). [Ref]::-moz-placeholder, but the old selector will still work for a while. [Ref]:-ms-input-placeholder. [Ref]::placeholder[Ref]Internet Explorer 9 and lower does not support the
placeholderattribute at all, while Opera 12 and lower do not support any CSS selector for placeholders.The discussion about the best implementation is still going on. Note the pseudo-elements act like real elements in the Shadow DOM. A
paddingon aninputwill not get the same background color as the pseudo-element.CSS selectors
User agents are required to ignore a rule with an unknown selector. See Selectors Level 3:
So we need separate rules for each browser. Otherwise the whole group would be ignored by all browsers.
Usage notes
opacity: 1here.emand test them with big minimum font size settings. Don’t forget translations: some languages need more room for the same word.placeholderbut without CSS support for that (like Opera) should be tested too.inputtypes (email,search). These might affect the rendering in unexpected ways. Use the properties-webkit-appearanceand-moz-appearanceto change that. Example: