Last Updated : 05 Oct, 2021
We know that the placeholder attribute is used to define a hint of what value has to be entered on the input and textarea field. This attribute is used for a better understanding of form structure. It contains a string value that represents the short hint that describes the expected value of an input field/text area. The short hint is displayed in the field before the user enters a value. This attribute is used to better understand from what type of data has to be entered into a particular field.
It can be used in the <input> and <textarea> element.
Syntax:
<element placeholder="">
Example: Below example illustrates the use of the placeholder attributes.
HTML
<!DOCTYPE html>
<html>
<body>
<center>
<h1 style="font-size:25px;
font-style:italic;">
GeeksforGeeks
</h1>
<h2 style="font-size:25px;
font-family;Impact">
How to use placeholder attribute in HTML?
</h2>
<form action=" ">
<input type="text" name="Ename"
placeholder="Enter username or Email Address">
<br>
<input type="Password" name="lname"
placeholder="password">
<br>
<input type="submit" value="Submit">
</form>
</center>
</body>
</html>
Output:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4