The placeholder attribute adds a hint to an <input> element.
The hint appears as muted text inside the control and specifies what data to enter.
A placeholder attribute on two <input> elements.
The placeholders specify the data that the input boxes expect.
<form action="/tutorial/action.html">
<input type="text" name="firstname" placeholder="Enter first name"><br /> <br />
<input type="text" name="lastname" placeholder="Enter last name"><br /> <br />
<input type="submit">
</form>
The placeholder attribute adds a hint to the input element.
The hint appears as muted text inside the control. It disappears when the user starts entering data.
Placeholders only apply to these input types:
<input placeholder="text">
Value | Description |
---|---|
text | String value. The hint text. |
Here is when placeholder support started for each browser:
Chrome
|
10.0 | Mar 2011 |
Firefox
|
4.0 | Mar 2011 |
IE/Edge
|
10.0 | Sep 2012 |
Opera
|
11.0 | Dec 2010 |
Safari
|
5.0 | Jun 2010 |
Back to <input>