placeholder

A short hint displayed inside a form field before the user types. Useful for format hints, but never a replacement for labels.

Overview

The placeholder attribute displays a short hint inside a form field when it is empty. The text disappears as soon as the user starts typing. It is meant for brief format hints — not labels, instructions, or anything the user might need to reference while filling out the field.

Applies to: <input> (text-like types), <textarea>

Values

Input TypeGood PlaceholderWhy
emaile.g., jane@example.comShows expected format
tel123-456-7890Clarifies separator style
urlhttps://example.comReminds to include protocol
text (date)MM/DD/YYYYShows date format
searchSearch articles...Clarifies scope
number0.00Shows decimal precision

Placeholder Is Not a Label

This is the single most common accessibility mistake in form design. A placeholder is not a label. It fails as a label in several ways:

  • It disappears. Once the user starts typing, the hint is gone. They cannot verify what the field is asking for.
  • Low contrast. Placeholder text is intentionally muted. It often fails WCAG contrast requirements.
  • No guaranteed accessibility. Not all screen readers announce placeholder text consistently. The <label> element is the only reliable way to name a field.
  • Confuses autofill. Users with cognitive disabilities may mistake placeholder text for a pre-filled value and skip the field.

Better Alternatives to Placeholder

For instructions, validation hints, or anything the user needs to see while typing, use persistent helper text below the field.

Helper text is always visible, always accessible, and does not disappear. Use placeholder for short format hints (like MM/DD/YYYY) and helper text for everything else.

Textarea

The placeholder attribute works on <textarea> as well. It disappears when the user types any content.

Styling

Use the ::placeholder pseudo-element to style placeholder text, and :placeholder-shown to style the input when the placeholder is visible (i.e., the field is empty).

Firefox note: Firefox renders placeholders at reduced opacity by default. Add opacity: 1 to ::placeholder if you want consistent appearance across browsers.

Accessibility

  • Always provide a visible <label> element. Never use placeholder as the only field label.
  • Placeholder text should meet WCAG 1.4.3 contrast requirements (4.5:1 ratio for normal text), though in practice most default browser styles fall short. Test your placeholder color.
  • Keep placeholder text short. Screen readers that do announce it will read the entire string, and long placeholders are disruptive.
  • Do not put instructions or validation rules in the placeholder. Use <small> helper text or aria-describedby instead.

Limitations

  • Placeholder text is not submitted with the form. If the user leaves the field empty, the placeholder is not sent as the value.
  • placeholder does not work on <select>. Use an empty-value first option instead: <option value="">Choose...</option>.
  • Placeholder text cannot contain HTML. Line breaks and formatting are ignored.
  • The ::placeholder pseudo-element only accepts a subset of CSS properties (color, font, text-related). You cannot add borders, backgrounds, or pseudo-content to it.
  • Password managers may not correctly identify fields that rely on placeholder instead of <label> for context.

See Also