HTML placeholder Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The placeholder attribute shows brief hint text in a form control when it has no value. Use a short example of the expected data (for example e.g. [email protected]), not a full prompt or label.

Supported on text, search, url, tel, email, password, and <textarea>. Always pair with a <label>. Related: value, required, and pattern.

Standard HTML attribute.

Not deprecated and not experimental. Widely supported across modern browsers for the input types listed above and for textarea.

Accessibility warning.

Per MDN: never use placeholder instead of a <label>. Placeholder text has lower contrast, disappears while typing, and is not announced like a label by default.

HTML Syntax

syntax.html
<input|textarea placeholder=" text">

text is the hint shown while the control is empty. Equivalent JS: el.placeholder = "hint".

Attribute Values

The value is plain text (a short hint). Common patterns:

Value / patternDescriptionTry it
e.g. …Example of expected data (best practice)Try it
On textareaHint for multi-line input (may include line breaks)Try it
vs valueHint vs real submitted dataTry it
+ <label>Required for accessibility — always include a labelTry it

Live Preview

The field has a visible label plus a short placeholder. Type to see the hint disappear; clear the field to bring it back.

Control

Placeholder is only a hint — the label names the field.

Preview

Empty — placeholder visible.

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Label with an Example Hint

Correct pattern: visible label, short example in placeholder.

HTML
<label for="name">Full name</label>
<input id="name" name="name" type="text"
       placeholder="e.g. Ada Lovelace">
Try It Yourself

How It Works

  1. <label for> names the field for everyone, including assistive tech.
  2. placeholder shows only while the value is empty.
  3. Keep the hint short — an example of the data type, not instructions.
  4. Typing clears the hint — the label must still explain the field.

Example 2 — Textarea Placeholder

Same idea for multi-line text; textarea may include line breaks in the hint.

HTML
<label for="bio">Short bio</label>
<textarea id="bio" name="bio" rows="4"
  placeholder="e.g. I build small web apps."></textarea>
Try It Yourself

How It Works

  1. Label the textarea the same way as an input.
  2. Placeholder appears when there is no text content.
  3. On <input>, line feeds clip the placeholder — keep one line.
  4. On <textarea>, multiline placeholders are allowed per MDN.

Example 3 — placeholder vs value

One field uses a hint; the other has a real default value.

HTML
<label for="city1">City (placeholder)</label>
<input id="city1" name="city1" type="text"
       placeholder="e.g. Paris">

<label for="city2">City (value)</label>
<input id="city2" name="city2" type="text"
       value="Paris">

<p id="note">Only value is submitted as data.</p>
Try It Yourself

How It Works

  1. Placeholder is gray hint text — not the control’s value.
  2. Value is actual content the user (or page) put in the field.
  3. On submit, empty + placeholder sends nothing for that name; value="Paris" sends Paris.
  4. Do not use value to fake a placeholder — users must delete it.

Edge Cases & Pitfalls

Most accessibility bugs are missing labels or putting the only instructions in the placeholder.

a11y

Not a label replacement

Screen readers announce labels; placeholders are often skipped. Keep a real <label>.

contrast

Lower contrast by design

Placeholder text is intentionally lighter than real input text. Do not rely on it for critical instructions.

types

Limited input types

Per MDN: text, search, url, tel, email, password (+ textarea). Not for select, checkbox, or radio.

newline

No line breaks in input

LF/CR in an <input> placeholder clip the text. Use one short line.

submit

Not form data

Placeholder is never submitted. Only value (typed or set) is.

Browser Support

placeholder is an HTML attribute for text-like inputs and textarea in the browser. It is not a Node.js, Deno, or Bun API.

✓ Widely available

placeholder

Supported in all modern browsers for text-like inputs and textarea. Keep using labels for accessibility regardless of support.

97% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet Modern
Full support
Internet Explorer 10+
Supported
placeholder Widely supported

Bottom line: Safe to use as a short empty-state hint. Always include a visible label, and never store the only instructions in the placeholder.

Key Takeaways

  • Role: short example hint while the field is empty.
  • Always use a <label> — placeholder is not a label.
  • Not submitted — unlike value.
  • Types: text-like inputs + textarea (per MDN).

One line: placeholder is a short empty-state example — label the field, then optionally hint.

Frequently Asked Questions

It shows brief hint text inside a form control when the control has no value. The hint disappears when the user enters data. It is not submitted with the form.
Per MDN: input types text, search, url, tel, email, and password, plus textarea. It is not for select, checkbox, radio, or button.
No. MDN: never use placeholder instead of a label. Labels stay visible, associate programmatically with the control, and are announced by screen readers; placeholders are not a reliable label.
value is real form data that can be submitted. placeholder is temporary empty-state hint text and is not sent on submit.
On input, LF/CR are not allowed and clip the text. On textarea, multiline placeholder text is allowed.
No. It is a standard HTML attribute. The main caution is accessibility: use it only as a short example/hint alongside a real label.

Next: poster

Show an image on a video before playback starts.

poster tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful