How to Change an HTML input's placeholder color with CSS?
How to Change an HTML input's placeholder color with CSS?
24729-Aug-2023
Updated on 02-Sep-2023
Home / DeveloperSection / Forums / How to Change an HTML input's placeholder color with CSS?
How to Change an HTML input's placeholder color with CSS?
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
::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
In this code, the
input::placeholder
selector is used to select all input elements. Thecolor
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 idmy-input
to blue:CSS
In this code, the
input#my-input::placeholder
selector is used to select the input element with the idmy-input
. Thecolor
property is set to blue.