HTML value Attribute
Definition and Usage
For button, input and option elements, the value attribute specifies the initial value of the element.
For li elements, the value attribute sets the value of an ordered list item. The following list items will increment from that number.
For progress elements, the value attribute specifies how much of the task has been completed.
For param elements, the value attribute specifies the value of a <param> element.
Applies to
The type attribute can be used on the following elements:
Elements | Attribute |
---|---|
<button> | value |
<input> | value |
<li> | value |
<option> | value |
<progress> | value |
<param> | value |
Examples
Button Example
Two buttons with equal names, that submit different values when clicked:
Choose your favorite subject:
<button name="subject" type="submit" value="fav-HTML">HTML</button>
<button name="subject" type="submit" value="fav-CSS">CSS</button>
</form>
Input Example
An HTML form with initial (default) values:
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">
</form>
Li Example
Use of the value attribute in an ordered list:
<li value="100">Coffee</li>
<li>Tea</li>
<li>Milk</li>
<li>Water</li>
<li>Juice</li>
<li>Beer</li>
</ol>
Option Example
A drop-down list inside an HTML form:
<select name="cars">
<option value="volvo">Volvo XC90</option>
<option value="saab">Saab 95</option>
<option value="mercedes">Mercedes SLK</option>
<option value="audi">Audi TT</option>
</select>
<input type="submit" value="Submit">
</form>
Progress Example
Downloading in progress:
Param Example
Set the "autoplay" parameter to "true", so the sound will start playing as soon as the page loads:
<param name="autoplay" value="true">
</object>
Browser Support
The value
attribute has the following browser support for each element:
Element | |||||
---|---|---|---|---|---|
button | Yes | Yes | Yes | Yes | Yes |
input | 1.0 | 2.0 | 1.0 | 1.0 | 1.0 |
li | Yes | Yes | Yes | Yes | Yes |
option | Yes | Yes | Yes | Yes | Yes |
progress | 8.0 | 10.0 | 16.0 | 6.0 | 11.0 |
param | Yes | Yes | Yes | Yes | Yes |