value (HTML attribute)

Spec
Depr. Version
No HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

value="value"

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 Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full 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.

Related Products