The Placeholder Arribute in HTML5
The placeholder attribute is used for providing a hint to the user during form entry. Placeholder text is
appeared in the input field and it disappeared when the corresponding field gets focus.
Now we use to placeholder attribute. Its syntax is given below:
<input type="type" name="name" placeholder="Hint Text" >
We write the following code:
- <!DOCTYPE HTML>
- <html>
- <body>
- <form method="get">
- First Name
- <input type="text" name="fname" placeholder="Your First Name" />
- <br/>
- Last Name
- <input type="text" name="lname" placeholder="Your Last Name"/>
- <br/>
- Email
- <input type="email" name="EMail" placeholder="Your email id"/>
- <br/>
- <input type="submit" />
- </form>
- </body>
- </html>
Then we run this code. The output will look like as below: