input value Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:input

Description

The value attribute specifies the value of an <input> element.

The value attribute is used differently for different input types:

  • For "button", "reset", and "submit" - it defines the text on the button
  • For "text", "password", and "hidden" - it defines the initial (default) value of the input field
  • For "checkbox", "radio", "image" - it defines the value associated with the input (this is also the value that is sent on submit)

The value attribute cannot be used with <input type="file">.

Attribute Values

Value Description
text Specifies the value of the <input> element

An HTML form with initial (default) values:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<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><!--from  w  ww.ja  v a 2s  . c  o  m-->

</body>
</html>

Related Tutorials