W3Schools.com

HTML5 <input> placeholder Attribute

HTML5 input Tag Reference HTML5 <input> tag

Example

Two input fields with a placeholder text:

<form action="demo_form.asp">
  <input type="text" name="fname" placeholder="First name" /><br />
  <input type="text" name="lname" placeholder="Last name" /><br />
  <input type="submit" value="Submit" />
</form> 

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The placeholder attribute is supported in all major browsers, except Internet Explorer.


Definition and Usage

The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format).

The hint is displayed in the input field when it is empty, and disappears when the field gets focus.

Note: The placeholder attribute works with the following input types: text, search, url, tel, email, and password.


Differences Between HTML 4.01 and HTML5

The placeholder attribute is new in HTML5.


Syntax

<input placeholder="text" />

Attribute Values

Value Description
text Specifies a short hint that describes the expected value of the input field


HTML5 input Tag Reference HTML5 <input> tag
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE