value (HTML attribute)
Example
A pre-defined
value set for a text input:
<input type="text" name="search" value="Enter search phrase" />
Description
The value
attribute is used/displayed differently depending on the type of form control, as detailed in the following
list:
type="button","submit","reset": the text stated in thevalueattribute will be used as the button’s text, and cannot be changed by the user (although it could potentially be changed dynamically via JavaScript)type="text","password": thevaluewill appear inside theformcontrol and may be overtyped/copied/cut by the user (note that if displayed in the password field, it will be obfuscated, but the correct number of characters will appear nonetheless)type="radio","checkbox","image","hidden": thevaluewill not be displayed to the user, nor can it be changed, but it will be associated with the control and is what gets passed on when theformis submitted
Note that the properties chart does not show the
value attribute as required for all input types,
but in the case of radio and checkbox input types, the
value attribute is
required.
Value
Any name or value that the developer chooses.
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
Causes no compatibility issues. It has excellent support across all tested browsers.
User-contributed notes
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

