How to Change an HTML input's placeholder color with CSS?
How to Change an HTML input's placeholder color with CSS?
495
29-Aug-2023
Updated on 02-Sep-2023
Aryan Kumar
02-Sep-2023Sure, 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.