Skip to: content, navigation

by Ian Lloyd

value (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
No HTML 2
value="value"

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 the value attribute 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": the value will appear inside the form control 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": the value will 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 the form is 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

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

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.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters