Chrome supports the placeholder attribute on input[type=text]
elements (others probably do too).
But the following CSS
doesn\'t do anything
Use the new ::placeholder
if you use autoprefixer.
Note that the .placeholder mixin from Bootstrap is deprecated in favor of this.
Example:
input::placeholder { color: black; }
When using autoprefixer the above will be converted to the correct code for all browsers.
Now we have a standard way to apply CSS to an input's placeholder : ::placeholder
pseudo-element from this CSS Module Level 4 Draft.
The easiest way would be:
#yourInput::placeholder {
color: red;/*As an example*/
}
/* if that would not work, you can always try styling the attribute itself: */
#myInput[placeholder] {
color: red;
}
For Sass users:
// Create placeholder mixin
@mixin placeholder($color, $size:"") {
&::-webkit-input-placeholder {
color: $color;
@if $size != "" {
font-size: $size;
}
}
&:-moz-placeholder {
color: $color;
@if $size != "" {
font-size: $size;
}
}
&::-moz-placeholder {
color: $color;
@if $size != "" {
font-size: $size;
}
}
&:-ms-input-placeholder {
color: $color;
@if $size != "" {
font-size: $size;
}
}
}
// Use placeholder mixin (the size parameter is optional)
[placeholder] {
@include placeholder(red, 10px);
}
Here is one more example:
.form-control::-webkit-input-placeholder {
color: red;
width: 250px;
}
h1 {
color: red;
}
<div class="col-sm-4">
<input class="form-control" placeholder="Enter text here.." ng-model="Email" required/>
</div>
Compass has a mixin for this out of the box.
Take your example:
<input type="text" placeholder="Value">
And in SCSS using compass:
input[type='text'] {
@include input-placeholder {
color: #616161;
}
}
See docs for the input-placeholder mixin.