HTML value Attribute
Description
The HTML value attribute is used to define the initial or default value of an input element such as <input>, <button>, <option>, <meter>, or <progress>. It specifies the value that will be displayed or submitted when the form is initially loaded or reset.
For example, in an <input> element of type "text" or "number", the value attribute defines the initial text displayed in the input field. Similarly, in a <button> element, it sets the initial label displayed on the button. In <option> elements within a <select> element, the value attribute specifies the value that will be submitted if that option is selected.
Here's a basic example of its usage:
<input type="text" value="Default Text">
In this example, the initial value of the text input field will be "Default Text".
It's important to note that while the value attribute sets the initial value, users can still change this value interactively in the browser. If you want to prevent user modification, you might consider using the readonly attribute in conjunction with value, or setting the disabled attribute if user input should be entirely disabled.
Syntax
<tagname value="text">
Values
- textAn alphanumeric string.
Example
Browser Support
The following information will show you the current browser support for the HTML value attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.
This attribute is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 30th March 2024
