English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <input> placeholder Attribute

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.

 HTML <input> tag

Example 1

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.

Online Example 2

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 ‹/›

Browser Compatibility

The numbers in the table indicate the first browser version that supports this attribute.

Attribute




placeholder10.010.04.05.011.0

Definition and Usage

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.

HTML 4.01 with HTML5difference

The placeholder attribute is an HTML5 new attribute added to the list.

Syntax

<input placeholder="text">

Attribute value

ValueDescription
textSpecify a short hint that describes the expected value of the input field.
 HTML <input> tag