👀 Live Preview
Username field with placeholder — type to see the hint disappear:
The label stays visible; placeholder is only a hint inside the empty field.

The placeholder attribute shows hint text inside an empty <input> or <textarea>. It gives users a short example or format cue — like “Enter your username” or 555-123-4567 — and disappears when they type. It is not a label: always pair placeholders with a real <label>. Placeholder text is not submitted with the form (unlike value). Use it with pattern for format examples, and set element.placeholder in JavaScript when hints change dynamically.
Empty field.
Text fields.
Multi-line.
Use both.
JS property.
Not submitted.
placeholder AttributeThe primary purpose of placeholder is to improve form usability with a visual hint about what to enter or how to format input. A phone field might show 555-123-4567; a search box might show Search products….
Placeholders supplement labels — they do not replace them. Once the user starts typing, the hint vanishes, so critical field names must live in an associated <label>. For validation rules, use pattern, minlength, or helper text outside the field.
Only value (what the user entered) is submitted. Placeholder text never appears in the POST body — it is display-only.
Add placeholder with a string hint on input or textarea:
<label for="username">Username:</label>
<input
type="text"
id="username"
name="username"
placeholder="Enter your username">
<label for="bio">Bio:</label>
<textarea id="bio" placeholder="Tell us about yourself…"></textarea>input (most text-entry types) and textarea.select, button, checkbox, or radio.<label for="…"> — do not use placeholder as the only label.input.placeholder = "New hint".pattern when showing an example format (placeholder = hint, pattern = rule).The placeholder attribute accepts any text string:
placeholder="Enter your username" — Descriptive hint.placeholder="555-123-4567" — Format example for phone.placeholder="Search…" — Search box cue.placeholder="Describe your issue…" — Multi-line textarea hint.<input type="email" placeholder="you@example.com">
<input type="search" placeholder="Search docs…">
<textarea placeholder="Your message here"></textarea>| Concept | Behavior | Submitted? |
|---|---|---|
placeholder | Hint when empty | No |
value | Actual field content | Yes |
<label> | Accessible field name | N/A |
input.placeholder | JS read/write hint | N/A |
With pattern | Hint + validation rule | pattern validates value |
textarea | Multi-line hints | No (hint only) |
| Element / type | Supported? | Notes |
|---|---|---|
<input type="text"> | Yes | Most common |
email, password, tel, url, search | Yes | Text-entry types |
number, date, time | Yes | Browser-dependent display |
<textarea> | Yes | Multi-line hints |
checkbox, radio, file | No | Not applicable |
<select>, <button> | No | Use first option or button text |
placeholder vs label vs value| Attribute / element | Purpose | When visible |
|---|---|---|
placeholder | Hint / example | Only when field is empty |
<label> | Field name (required for a11y) | Always visible |
value | Pre-filled or user data | While field has content |
pattern | Validation regex | Not visible (rule only) |
Login form hints, dynamic placeholder in JavaScript, and textarea placeholder text.
Username field with placeholder — type to see the hint disappear:
The label stays visible; placeholder is only a hint inside the empty field.
Hints on username and password fields with proper labels:
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username"
placeholder="Enter your username">
<label for="password">Password:</label>
<input type="password" id="password" name="password"
placeholder="Enter your password">
<button type="submit">Submit</button>
</form>Placeholders show inside empty fields. Labels remain visible for accessibility. Only typed values are submitted — not the placeholder text.
Change the hint when context changes:
<input type="text" id="dynamicField">
<script>
document.getElementById("dynamicField").placeholder = "Search by product name…";
</script>The placeholder IDL property accepts a string. Updating it changes the hint immediately without affecting value.
Multi-line hint for a message or feedback field:
<label for="message">Your message:</label>
<textarea
id="message"
name="message"
rows="4"
placeholder="Describe your issue in detail…"></textarea>textarea uses the same placeholder attribute. Keep the <label> for the field name; use placeholder for an optional example of what to write.
<label> is.for / id on every input and textarea.value for real default data, not placeholder.No value yet.
placeholder text.
Hint hides.
With real labels.
The placeholder attribute on input and textarea is supported in all modern browsers.
placeholder supportHint text works on inputs and textareas in every major browser.
Bottom line: Safe for form hints on input and textarea in all modern browsers.
placeholder with a visible <label>pattern when showing format examplesinput.placeholder when context changes in JSplaceholder with valueselect or buttonpattern, required)The placeholder attribute shows hint text in empty input and textarea fields — a simple way to guide users without replacing proper labels.
Keep labels visible, use placeholders for short examples, and remember that only value is submitted with the form.
placeholderBookmark these before building forms.
Not data.
RoleSupported.
ScopeAlways.
A11yJS update.
APINot submitted.
Gotchainput or textarea. The hint disappears when the user types. It is not submitted with the form.<label>. Placeholder text vanishes on input and is not a reliable accessible name for the field.value is real data (pre-filled or typed) that gets submitted. placeholder is temporary hint text shown only when the field is empty.textarea uses the same placeholder attribute as input for multi-line hints.element.placeholder = "New hint text" on the input or textarea element.input and textarea in all modern browsers (IE 10+).Practice the placeholder attribute on login forms, dynamic hints, and textareas in the Try It editor.
5 people found this page helpful