Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to use placeholder attribute in HTML ?

  • 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:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!