11 / 17

What is the placeholder attribute?

Using the placeholder Attribute in HTML

The placeholder attribute in HTML specifies a short hint or example text that is displayed inside an input field or textarea before the user enters a value. It helps guide users about the expected type of input.

Key Points About placeholder
  1. 1

    Works with <input> and <textarea> elements.

  2. 2

    The text disappears when the user types something into the field.

  3. 3

    It should be used as a hint or example, not as a replacement for labels.

  4. 4

    Does not enforce validation or restrictions — it’s only a visual guide.

Example of placeholder Usage