How to specify the value of an input element using HTML ?
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;" > w3wiki </ h1 > < h2 > How to specify the value of an input element using HTML? </ h2 > Input Value: < input type = "text" value = "w3wiki" > </ 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;" > w3wiki </ h1 > < h2 > How to specify the value of an input element using HTML? </ h2 > < input type = "button" value = "Submit" > </ body > </ html > |
Output:
Contact Us