Html placeholder attribute assignment expert

Answer to Question #303825 in HTML/JavaScript Web Application for taufiq umar

HTML Placeholder Attribute

Placeholder Attribute.

Use the below reference image link:.

https://assets.ccbp.in/frontend/content/dynamic-webapps/ce-3-2-1-html-placeholder-attribute-op.png

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>Let's Ride</h2>
    <p>Free bike rides to join, and great cycle routes to explore.</p>
    <input type="text" placeholder="Enter your Location">
</body>
</html>

Answer to Question #256219 in HTML/JavaScript Web Application for sagun poudel

Create a form, using HTML, for admission to a University. The form should ask for the following information:  Your email id as user name (it should be of the type )  A pin chosen by you (should have a minimum size of 4 decimal digits)  Name of the Student  City in which student is residing (You should create a drop-down list of about 4 to 6 cities for selection of City, default value for City should be Mumbai)  Select from the options Yes/No for the question Mathematics at 10+2?  The form should include a SUBMIT button.

<html>
  <head>
    <title>Admission to a University</title>
  </head>
  <body>
    <form>
      <input type="email" placeholder="Email"/>
      <input type="number" min_length="3" placeholder="Pin"/>
      <input type="name" placeholder="Number"/>
      <input type="city" placeholder="City"/>
      <select>
        <option value="yes">Yes</option>
        <option value="no">No</option>
      </select>
      <input onsubmit="onSubmit()">Sumbit</input>
    </form>
    <script>
      function onSubmit() {
        // implementation
      }
    <script>
  </body>
</html>

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    The 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="">

    Elements: This method can have following attributes: 
     

    • <input> placeholder Attribute
    • <textarea> placeholder Attribute

    Attribute: The attribute for each of the above element is placeholder. 
    Example: With <input> element 
     

    html

    <!DOCTYPE html>

    <html>

    <body>

        <center>

            <h2 style="font-size:25px;font-style:italic;">

                GeeksforGeeks

            </h2>

            <h2 style="font-size:25px;font-style:italic;">

            Placeholder Attribute in Input Element

            </h2>

            <form action=" ">

                <input type="text" name="fname"

                                placeholder="First name">

                <br>

                <input type="text" name="lname"

                                placeholder="Last name">

                <br>

                <input type="submit" value="Submit">

            </form>

    </center>

    </body>

    </html>

    Output: 
     

    Html placeholder attribute assignment expert

    Example: With <textarea> element 
     

    html

    <!DOCTYPE html>

    <html>

    <body>

        <center>

            <h2 style="font-size:25px;font-style:italic;">

            GeeksForGeeks

            </h2>

            <h2 style="font-size:25px;font-style:italic;">

            Placeholder Attribute in Textarea Element

            </h2>

            Give your Intro:

            <textarea rows="4" cols="40"

            placeholder="Write something here about yourself...">

            </textarea>

    </center>

    </body>

    </html>

    Output: 
     

    Html placeholder attribute assignment expert

    Supported Browsers: The browser supported by placeholder Attribute are listed below: 
     

    • Google Chrome
    • Internet Explorer
    • Firefox
    • Opera
    • Safari

    What is placeholder attribute in HTML?

    The placeholder attribute specifies a short hint that describes the expected value of a input field / textarea. The short hint is displayed in the field before the user enters a value.

    How do you give a textbox a hint in HTML?

    If you want to set a hint for text area or input field, then use the HTML placeholder attribute. The hint is the expected value, which gets displayed before the user enters a value, for example, name, details, etc.