CKTIS / HTML
input — form control
The `input` element represents a data field or button depending on `type`. Learn how to choose its type, provide a label and submission name, and apply basic value constraints.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<input type="text" id="username" name="username" value="Ada" required>input represents a typed data field, usually with a control for editing it. type selects behavior, for example text, email, number, checkbox, or submit. A missing or invalid type means text. The element has no content or end tag.
Provide a visible label: its for references the control's id. placeholder does not replace a label. name determines the data name for form submission; id alone does not provide one. For multiline text, use textarea.
Attribute applicability depends on the type. required requires a value or appropriate checked state; min, max, and step constrain supported values. disabled disables the control and omits it from submission. Where applicable, readonly prevents editing but does not exclude the value from submission. Client-side validation does not replace server-side checks.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Input example</title>
<form>
<label for="username">Username</label>
<input type="text" id="username" name="username" value="Ada" required>
</form>
<pre id="result"></pre>
<script>
const field = document.getElementById('username');
document.getElementById('result').textContent =
field.value + '\n' + field.checkValidity();
</script>
</html>Result
Ada true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.