How to change placeholder color

Learn how to use CSS to change the color of placeholder attributes.

Try It Yourself

How to change placeholder color

Step 1 - Add HTML:

Use an input element and add placeholder Attribute:

<input type="text" placeholder="A red placeholder text..">

Step 2 - Add CSS:

The placeholder text is usually gray in most browsers. To change this setting, please use ::placeholder selector to set the placeholder style.

Please note that Firefox adds a lower opacity to placeholders, so we use opacity: 1 To solve this problem.

::placeholder {
  color: red;
  opacity: 1; /* Firefox */
{}
::-ms-input-placeholder { /* Edge 12 -18 */
  color: red;
{}

Try It Yourself

Related Pages

Reference Manual:CSS ::placeholder Selector