Open In App

HTML placeholder Attribute

Improve
Improve
Like Article
Like
Save
Share
Report

HTML placeholder attribute specifies a 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.

Syntax: 

<element placeholder="">

HTML placeholder Attribute Examples

Example 1: HTML <input> placeholder attribute specifies a short hint or example text displayed in an input field before the user enters a value. It helps users understand the expected input format or content.

HTML




<!DOCTYPE html>
<html>
<body>
    <h3>
        HTML placeholder Attribute Example
    </h3>
    <!-- HTML placeholder attribute used in input tag -->
    <form action=" ">
        <label for="First Name">Enter your first name:</label>
        <input type="text" name="fname" placeholder="First name">
        <br>
        <br>
        <label for="First Name">Enter your last name:</label>
        <input type="text" name="lname" placeholder="Last name">
        <br>
        <br>
        <input type="submit" value="Submit">
    </form>
</body>
  
</html>


Output: In this example, we demonstrate placeholder attributes in input elements. Two text input fields for first and last names. Placeholder text guides user input, improving form usability.

HTML-placeholder_attribute

HTML placeholder Attribute Example Output

Example 2: HTML