The placeholder attribute specifies a hint that describes the expected value of an input field (a sample value or a short description of the format). The hint is displayed in the input field before the user enters a value. The placeholder attribute works with the following input types: text, search, url, tel, email, and password.
This is an example of an input field with a placeholder text:
HTML file: | Displayed by browser: |
---|---|
<form action="http://www.w3schools.com/html/action_page.php">
<input type="text" name="fname" placeholder="First name"> <br /> <br /><input type="submit" value="Submit"> </form> |
This attribute is compatible with most major browsers.