Open In App

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

Improve
Improve
Like Article
Like
Save
Share
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:



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