CSS ::placeholder Pseudo-element
Example
Change the color and opacity of the placeholder text in input fields:
input::placeholder
{
color: red;
opacity: 0.5;
}
Try it Yourself »
Definition and Usage
The ::placeholder
pseudo-element is used to
style the placeholder text of <input> or <textarea> elements.
The placeholder text is set with the placeholder attribute, which specifies a hint that describes the expected value of the field.
Tip: The default color of the placeholder text is light grey in most browsers.
Version: | CSS Pseudo-elements Module Level 4 |
---|
Browser Support
The numbers in the table specify the first browser version that fully supports the pseudo-element.
Pseudo-element | |||||
---|---|---|---|---|---|
::placeholder | 57 | 79 | 51 | 10.1 | 44 |
CSS Syntax
::placeholder {
css declarations;
}
Related Pages
CSS Reference :placeholder-shown