::placeholder y2h4g
::placeholder is a CSS pseudo-element that represents placeholder text in an input field—text that represents the input and provides a hint to the on how to fill out the form. 2fx3d
For example, a date-input field might have the placeholder text “YYYY/MM/DD” to clarify that numeric dates are to be entered in year-month-day order. An input field that takes an email as a value may have “[email protected]” as placeholder text, hinting about the email format.
In most browsers, placeholder text is initially light grey colored. You can change the font style and color, for example, using the ::placeholder
pseudo-element.
All properties that apply to the ::first-line
pseudo-element also apply to the ::placeholder
pseudo-element.
Some browsers have their own non-standard implementations of the ::placeholder
pseudo-element. All of those implementations require browser prefixes. Examples of these implementations is ::-webkit-input-placeholder
, :-ms-input-placeholder
(single colon), and :-moz-placeholder
which has been deprecated in Firefox 19 in favor of the newer ::-moz-placeholder
pseudo-element.
Depending on the browser, the input placeholder may or may not stay visible when the input field takes focus. For example, IE10+ will hide the placeholder when the input is focused, even if it is still empty.
Examples 2t4m6h
The following snippet changes the default color and font family of the placeholder text on the page:
::placeholder { color: #96eb7f; font-family: Lato, sans-serif; }
Browser f3k20
input placeholder attribute 4d29g
Method of setting placeholder text for text-like input fields, to suggest the expected inserted information.
ed from the following versions:
Desktop 544w68
- 4
- 4
- 10
- 11
- 5
Mobile / Tablet 60z3k
- 3.2
- 2.1
- all
- 66
- 60
Further Reading 5h4k6b
- CSS Pseudo-elements Module Level 4
- HTML5 Placeholder Styling with CSS by David Walsh
- Recommended: Placeholder Title for Article about HTML5 Placeholders by Zach Leatherman