The ::placeholder pseudo-element styles the hint text shown inside an <input> or <textarea> before the user types.
It does not style the typed value. Only a limited set of text-like properties apply (similar to ::first-line): mainly color, font, opacity, and text decoration.
Baseline Widely available.
Supported across modern browsers. Prefer the standard ::placeholder form.
Warning — not a label.
Placeholders disappear on input and must not replace a visible, associated <label>.
Deprecated — vendor prefixes.
Skip ::-webkit-input-placeholder, ::-moz-placeholder, and :-ms-input-placeholder unless you must support very old browsers.
Syntax
CSS Syntax
syntax.css
::placeholder{ /* styles */ }
Commonly scoped: input::placeholder or textarea::placeholder.
Scope by element.input::placeholder and textarea::placeholder stay separate.
Style inputs with a stronger hint color for short fields.
Style textareas with a softer, italic hint for longer copy.
Keep labels. Each control still has its own accessible name.
Edge Cases & Pitfalls
Most issues are about accessibility, not syntax.
a11y
Never replace labels
Screen readers and sighted users need a lasting label. Put examples outside the field with aria-describedby when needed.
contrast
Balance contrast
Too light fails WCAG; too strong looks like real input. Aim for readable gray that still differs from typed text.
props
Limited properties
Only a ::first-line-like subset applies. Do not expect background or border on the placeholder itself.
vs shown
Not the same as :placeholder-shown
::placeholder styles the hint. :placeholder-shown matches the control while that hint is visible.
opacity
Browser opacity defaults differ
Set color explicitly and often opacity: 1 so Firefox, Chrome, and Safari look alike.
Compatibility
Browser Support
::placeholder is a browser CSS pseudo-element. Node.js, Deno, and Bun do not evaluate it.
✓ Baseline · Widely available
::placeholder
Standard form widely supported since ~2020. Older engines needed vendor prefixes.
97%Modern browsers
Google Chrome57+
Full support
Mozilla Firefox51+
Full support
Apple Safari10.1+
Full support
Microsoft Edge79+
Full support
Opera44+
Full support
Samsung Internet7+
Full support
::placeholderWidely supported
Bottom line: Safe for modern forms. Prefer unprefixed ::placeholder. Not a server runtime API.
Remember
Key Takeaways
Role: style empty-state hint text in inputs and textareas.
Limits: text-like properties only — not full box styling.
A11y: always keep a real label; placeholders are optional hints.
Tip: set color (and often opacity: 1) for cross-browser consistency.
One line:::placeholder styles the hint text inside empty form fields — never the typed value.
Frequently Asked Questions
It styles the placeholder hint text inside an input or textarea — color, font, opacity, and similar text properties — without styling the value the user types.
Elements that show a placeholder attribute: input (text, email, search, tel, url, password, number, and similar) and textarea.
Only a limited set of properties apply (similar to ::first-line). Prefer color, font, opacity, and text-decoration. Background and border usually do not style the placeholder text itself.
::placeholder styles the hint text. :placeholder-shown is a pseudo-class that matches the control while the placeholder is visible (empty value).
No. Placeholders disappear when typing and are weak for accessibility. Always use a proper label; keep placeholders as short hints only.
No. It is a browser CSS pseudo-element, not a Node.js feature.