HTML placeholder attribute

placeholder attribute hints the user about data entry in the input field or textarea. Data entry means what kind of data should be entered in the input field.

<p>First name: <input type="text" placeholder="john"></p>
 <p>Last name: <input type="text" placeholder="david"></p>
 <p>Email <input type="email" placeholder="[email protected]"></p>
 <p>Password <input type="password" placeholder="password"></p>
</>

First name:

Last name:

Email

Password

Attribute values

All possible values of placeholder attribute

The value of this attribute is simple plain text.

Related Tags

The tags that support placeholder attribute

<input> tag

input tag allows the user to enter data. It supports placeholder attribute.

<p>Password: <input type="password" name="pass" placeholder="at least 8 digit"></p>
Try</>

If the hint is longer than the width of input element, then small element should be used as side comment to hint the user. placeholder is not suitable for the older people and users with vision impairments.



Was this article helpful?