CKTIS / HTML
The HTML value attribute
The value attribute has element-specific meanings: a control value, submitted form data, a measurement, progress, a list item's number, or a machine-readable representation. It is not a global attribute.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
value="..."value does not have one meaning across all elements. Its syntax and behavior depend on the element and, for input, on type. It is a text attribute in HTML source, but an element can interpret its contents as a number or another specified format.
For a text input, the attribute specifies the default value; the DOM property .value exposes the current value. After user editing or assignment to .value, they can differ. For checkbox and radio, value specifies the submitted value, not whether the control is checked. For input type="file", the value attribute must not be specified.
For button, value specifies the value submitted under its name when that button submits the form; the button's contents supply its label. For option, it specifies the option's value; when omitted, that value is derived from the option's text.
For meter, the required value is a numeric measurement within min–max (default 0–1). For progress, it represents completed work from 0 to max (default 1); omitting value means indeterminate progress, not zero. Both require a valid HTML floating-point number.
For li in an ol list, value is an integer that sets the item's ordinal number and subsequent numbering; do not use it on a child of ul or menu. For data, it is required and contains a machine-readable representation of the visible contents. The example demonstrates the difference between a text input attribute and its current .value.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Attribute and current value</title>
<label>City <input id="city" value="Paris"></label>
<pre id="result"></pre>
<script>
const city = document.getElementById('city');
city.value = 'Rome';
document.getElementById('result').textContent =
city.getAttribute('value') + '\n' + city.value;
</script>
</html>Result
Paris Rome
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.