juniorHTML5

What does the 'placeholder' attribute do?

Updated Apr 28, 2026

Short answer

It provides a short hint describing the expected value of an input field.

Deep explanation

The hint is displayed in the input field before the user enters a value. It should not be used as a replacement for the <label> tag, as it disappears once the user starts typing.

Real-world example

Showing 'MM/YY' inside a credit card expiration field to guide the user format.

Common mistakes

  • Using placeholder instead of <label>, which is bad for accessibility.

Follow-up questions

  • Can you style placeholders with CSS?

More HTML5 interview questions

View all →