HTML input value property
Examples
HTML form with the initial (default) values:
<form action="demo_form.php">
First name: <input type="text" name="fname" value="John"><br>
Last name: <input type="text" name="lname" value="Doe"><br>
<input type="submit" value="提交表单">
First name: <input type="text" name="fname" value="John"><br>
Last name: <input type="text" name="lname" value="Doe"><br>
<input type="submit" value="提交表单">
try it"
Browser Support
All major browsers support attribute value.
Definition and Usage
value attribute specifies the <input> element's value.
value attributes for different input types, usage is different:
- For the "button", "reset", "submit" type - Text Definition button
- For "text", "password", "hidden" types - initial definition of input field (default) value
- For the "checkbox", "radio", "image" type - defined elements associated with the input value when the form is submitted this value will be sent to the form's action URL.
Note: value attribute for <input type = "checkbox"> and <input type = "radio"> is required.
Note: value property does not apply <input type = "file"> .
Differences between HTML 4.01 and HTML5
no.
grammar
<input value="text">
Property Value
值 | 描述 |
---|---|
text | 规定 <input> 元素的值。 |
HTML <input> tag