English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML input placeholder attribute specifies a brief hint for the expected value of the input field (such as a sample value or a brief description of the expected format). This brief hint is displayed in the input box before the user enters a value.
Two input text fields with placeholder text:
<!DOCTYPE html> <html> <head> <title>HTML: <input> placeholder Attribute - Basic Tutorial Website(oldtoolbag.com)</title> <body> <form action="action_page.php"> <input type="text" name="fname" placeholder="First name"><br> <input type="text" name="lname" placeholder="Last name"><br> <input type="submit" value="Submit"> </form> </html>Test to see ‹/›
The placeholder text can also specify a color.
Set the color of placeholder text:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic Tutorial Website(oldtoolbag.com)</title> </head> <body> <form action="demo-form.php"> <input type="text" name="fname" placeholder="First name"><br> <input type="text" name="lname" placeholder="Last name"><br> <input type="submit" value="Submit"> </form> </body> </html>Test to see ‹/›
The numbers in the table indicate the first browser version that supports this attribute.
Attribute | |||||
---|---|---|---|---|---|
placeholder | 10.0 | 10.0 | 4.0 | 5.0 | 11.0 |
placeholder specifies a brief hint that describes the expected value of the input field (for example, a sample value or a brief description of the expected format).
A brief hint will be displayed in the input field before the user enters a value.
Note:placeholder attribute is applicable to the following input types: text, search, url, tel, email, and password.
The placeholder attribute is an HTML5 new attribute added to the list.
<input placeholder="text">
Value | Description |
---|---|
text | Specify a short hint that describes the expected value of the input field. |