Skip to content

Instantly share code, notes, and snippets.

@adamlaki
Last active July 28, 2018 05:46
Show Gist options
  • Save adamlaki/bd52d134881a5576dca4ddcf1ab2a8d2 to your computer and use it in GitHub Desktop.
Save adamlaki/bd52d134881a5576dca4ddcf1ab2a8d2 to your computer and use it in GitHub Desktop.
Set HTML5 Input's Placeholder Style with CSS
<form action="">
<input type="text" name="fname" placeholder="Your First Name">
</form>
input[type="text"]::-webkit-input-placeholder {
color: red;
}
input[type="text"]:-moz-placeholder {
color: #0db1ff; /* Firefox 4-18 */
}
input[type="text"]::-moz-placeholder {
color: #0db1ff; /* Firefox 19+ */
}
input[type="text"]:-ms-input-placeholder {
color: #0db1ff; /* IE10+ */
}
input[type="text"]::-ms-input-placeholder {
color: #0db1ff; /* Edge */
}
input[type="text"]::placeholder {
color: #0db1ff; /* Modern browsers */
}
@mixin placeholder($color) {
&::-webkit-input-placeholder {
color: $color;
}
&:-moz-placeholder {
color: $color;
}
&::-moz-placeholder {
color: $color;
}
&:-ms-input-placeholder {
color: $color;
}
&::-ms-input-placeholder {
color: $color;
}
&::placeholder {
color: $color;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment