Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

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 the list item (for ordered lists). The next list items will increment from that value.

For <meter> elements, the value attribute specifies the current value of the gauge.

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 the parameter.


Applies to

The value attribute can be used on the following elements:

Elements Attribute
<button> value
<input> value
<meter> value
<li> value
<option> value
<progress> value
<param> value

Examples

<button> Example

Two buttons with equal names, that submit different values when clicked:

<form action="/action_page.php" method="get">
  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>
Try it Yourself »

<input> Example

An HTML form with initial (default) values:

<form action="/action_page.php">
  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>
Try it Yourself »

<li> Example

Use of the value attribute in an ordered list:

<ol>
  <li value="100">Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
  <li>Water</li>
  <li>Juice</li>
  <li>Beer</li>
</ol>
Try it Yourself »

<meter> Example

A gauge with a current value, min, max, high, and low segments:

<meter min="0" low="40" high="90" max="100" value="95"></meter>
Try it Yourself »

<option> Example

A drop-down list inside an HTML form:

<form action="/action_page.php">
  <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>
Try it Yourself »

<progress> Example

Downloading in progress:

<progress value="22" max="100"></progress>
Try it Yourself »

<param> Example

Set the "autoplay" parameter to "true", so the sound will start playing as soon as the page loads:

<object data="horse.wav">
  <param name="autoplay" value="true">
</object>
Try it Yourself »

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
meter 8.0 13.0 6.0 6.0 11.0
option Yes Yes Yes Yes Yes
progress 8.0 10.0 16.0 6.0 11.0
param Yes Yes Yes Yes Yes

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.