value (HTML attribute)
| Depr. | Version |
|---|---|
| No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ |
|---|---|---|---|
| Full | Full | Full | Full |
Syntax
Description
The content contained between
the opening <option> and closing
</option> tags is the user-friendly version that’s displayed
on screen, but it’s what’s inside the value that’s
important to the processing application on the server. In the example
above, different foods are displayed on screen, but they have
values of "1",
"2", and "3", which should match up
with values in a database. If the value attribute
isn’t present, the content ("Cheese",
"Egg", and "Cabbage" in this
example) will be passed as a "value"
instead.
Example
In this example,
value attributes are specified for a series of
options:
<form>
<label for="favoritefood">Favorite food</label>
<select name="favoritefood" id="favoritefood" disabled="disabled">
<option value="1">Cheese</option>
<option value="2">Egg</option>
<option value="3">Cabbage</option>
⋮
</select>
</form>
Value
This attribute takes any name or value that the developer chooses.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.0 | 1.5 | 2.0 | 1.3 | 2.0 | 3.0 | 9.2 | 9.5 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
It causes no compatibility issues, and has excellent support across all tested browsers.
User-contributed notes
There are no comments yet.
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.