To change an HTMLinput's placeholdercolor with CSS, you can use the ::placeholder pseudo-element. The
::placeholder pseudo-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
input::placeholder {
color: red;
}
In this code, the input::placeholder selector is used to select all input elements. The
color property is set to red.
You can also use the color property 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 id
my-input to blue:
CSS
input#my-input::placeholder {
color: blue;
}
In this code, the input#my-input::placeholder selector is used to select the input element with the id
my-input. The color property is set to blue.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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.