How Input Value Defines Default Selection Fields Value
- Attribute of
- How To Use Input To Create Form Fields In HTML: Easy Tutorial
- What does
How Input Value Defines Default Selection Fields Valuedo? - Defines an initial value or default selection for an input field.
Contents
Code Example
<form>
<p>Please complete the form.</p>
<input type="text" name="yourname" value="Your Name"><br>
<input type="text" name="youremail" value="Your Email address"><br>
</form>The value of an input element defines its default settings. This is the default state of the form when the page is loaded, or when the reset button is pressed.
Default Behavior
The effects of value vary, depending on the type of input. Below is a brief summary of its functionality for some example input types.
Default Text Field Values
The value of a text or password field pre-fills the field with a default entry. In password fields, this value will always be obfuscated.
Default Selection Field Values
value can also be used to set the default state of checkboxes and radio buttons, so that certain selections are the default when the page loads. The user can then adjust the fields to their liking.
Other Types
When used with a hidden or image input type, the value sets a fixed entry for the field, which cannot be changed. The value of button, reset and submit input types defines the text on the button. A value for a file input will be ignored by the browser.