Skip to content
Related Articles
Open in App
Not now

Related Articles

How to use placeholder attribute in HTML ?

Improve Article
Save Article
  • Last Updated : 05 Oct, 2021
Improve Article
Save Article

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.


<element placeholder="">

Example: Below example illustrates the use of the placeholder attributes. 


<!DOCTYPE html>
        <h1 style="font-size:25px;
        <h2 style="font-size:25px; 
            How to use placeholder attribute in HTML?
        <form action=" ">
            <input type="text" name="Ename" 
                placeholder="Enter username or Email Address">
            <input type="Password" name="lname" 
            <input type="submit" value="Submit">


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!