The HTML placeholder attribute
The HTML placeholder attribute shows a short hint inside the empty field describing the expected value. It is used on the <input> and <textarea> elements.
Overview
The placeholder attribute shows faint hint text inside an empty <input> or <textarea> — an example value or format hint that disappears the moment the user starts typing.
The critical rule is that a placeholder is not a label. It vanishes on input, so the user loses the hint as they type; its default contrast is often too low to read comfortably; and it is not a reliable accessible name. Every field still needs a real <label> — treat the placeholder as supplementary at best.
Use it for a brief example (you@example.com) or a format hint (DD/MM/YYYY), never for essential instructions. Style the text — usually darkening it for readability — with the CSS ::placeholder pseudo-element.
Syntax
<input type="search" placeholder="Search…">
Values
| Value |
|---|
| A string of hint text. |
Example
<input type="search" placeholder="Search the docs…" aria-label="Search" style="padding:8px;width:100%;">
Best practices
Accessibility
Placeholder text is not a label — it disappears when typing and has poor contrast by default. Always provide a real <label> as well; use the placeholder only for an example or format hint.
Frequently asked questions
What does the placeholder attribute do?
Can a placeholder replace a label?
Why is placeholder text so faint?
::placeholder pseudo-element for readability.What is a good use for a placeholder?
you@example.com or DD/MM/YYYY.