HTML <input> valueAttribute

HTML input 标签参考手册HTML <input> Tag

Example

An HTML form with an initial (default) value:

<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="Submit Form">

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value attribute.


Definition and Usage

The value attribute specifies the value of an <input> element.

The usage of the value attribute differs for different input types:

  • For "button", "reset", and "submit" types - defines the text on the button
  • For "text", "password", and "hidden" types - defines the initial (default) value of the input field
  • For "checkbox", "radio", and "image" types - defines the value associated with the input element, which is sent to the form's action URL when the form is submitted.

Note:The value attribute is required for <input type="checkbox"> and <input type="radio">.

Note:The value attribute does not apply to <input type="file">.


Differences Between HTML 4.01 and HTML5

None.


Syntax

<input value="text">

Attribute Values

Value Description
text Specifies the value of the <input> element.


HTML input 标签参考手册HTML <input> Tag Other Extensions