How to Change an HTML input's placeholder color with CSS?
How to Change an HTML input's placeholder color with CSS?
Student
Skilled in SEO, content writing, and digital marketing. Completed several years of working in many organizations including multinational companies. I love to learn new things in life that keep me motivated.
Sure, I can help you with that.
To change an HTML input's placeholder color with CSS, you can use the
::placeholderpseudo-element. The::placeholderpseudo-element is used to style the placeholder text of an input element.The following CSS code shows how to change the placeholder color of an input element to red:
CSS
In this code, the
input::placeholderselector is used to select all input elements. Thecolorproperty is set to red.You can also use the
colorproperty to set the placeholder color of a specific input element. For example, the following CSS code will set the placeholder color of the input element with the idmy-inputto blue:CSS
In this code, the
input#my-input::placeholderselector is used to select the input element with the idmy-input. Thecolorproperty is set to blue.