Open In App
Related Articles

How to specify the value of an input element using HTML ?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

In this article, we will set the value of an input element using HTML. The value attribute for <input> element in HTML is used to specify the initial value of the input element. It has different meaning for different input type:

  • The “button”, “reset” and “submit” property specifies the text on the button.
  • The “text”, “password” and “hidden” property specifies the initial value of the input field.
  • The “checkbox”, “radio” and “image” property specifies the value associated with the input.

Syntax:

<input value = "value">

Attribute Value: It contains single value text which specifies the value of input element.

Example 1:

HTML

<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to specify the value of an
        input element using HTML?
    </title>
</head>
  
<body style="text-align:center">
  
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
  
    <h2>
        How to specify the value of an
        input element using HTML?
    </h2>
  
    Input Value: <input type="text" 
        value="GeeksforGeeks">
</body>
  
</html>

                    

Output:

Example 2:

HTML

<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to specify the value of an
        input element using HTML?
    </title>
</head>
  
<body style="text-align:center">
  
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
  
    <h2>
        How to specify the value of an
        input element using HTML?
    </h2>
  
    <input type="button" value="Submit">
</body>
  
</html>

                    

Output:


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!


Last Updated : 25 Dec, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials