Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <input> value Attribute

The value attribute on an <input> tag sets the value of the element.

The meaning and usage of the value depends on type of <input> element.

Example

#

Different <input> types, each one with a value.
These values are sent during form submission.

Edit User Information First name  

Last name  

       

<form action="/tutorial/action.html">
 <fieldset>
  <legend>Edit User Information</legend>

    First name &nbsp; <input type="text" name="firstname" value="Alex"><br /><br />
    Last name &nbsp; <input type="text" name="lastname" value="McNeil"><br /><br />
  
    <label>Gender</label> &nbsp;
    &nbsp; <label for="male"><input type="radio" id="male" name="gender" value="male" checked> Male</label>
    &nbsp; <label for="female"><input type="radio" id="female" name="gender" value="female"> Female</label>
    &nbsp; <label for="other"><input type="radio" id="other" name="gender" value="other"> Other</label><br /><br />

    <input type="hidden" name="userid" value="819404">

   <input type="submit" value="Submit">
 </fieldset>
</form>

Using value

The value attribute specifies the value of the input element.

The semantics (meaning) of the value attribute depends on the input type. For example:

  • For button, reset, and submit, the value is used as the button text.
  • For text, password, and hidden, the value serves as the initial value.
  • For checkbox, radio, and image, the value is submitted when selected or clicked.

Note: The value attribute applies to all input types, except type="file".


Syntax

<input value="text">

Values

#

Value Description
text An alphanumeric string.

Browser support

Here is when value support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <input>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides