Input Types
HTML input type="number"
Collect a numeric quantity; use min, max and step to constrain it. Do not use it for identifiers such as postal codes. Default step is 1; use step="any" for arbitrary increments. Use strings for postal codes and account numbers. Use only attributes applicable to this input state; the browser ignores or rejects unrelated constraints. Validate submitted data on the server.
Formal Syntax & Structure
html syntaxhtml
<input type="number">Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| type | literal number | Selects the number input state. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| value | element-dependent text or number | Default value or submitted value depending on type. A file input cannot be prefilled with a path. |
| min | number or type-specific date/time | Sets the lower constraint for eligible inputs or the lower bound of meter. It must use the type's value syntax; the effect depends on the element. |
| max | number or type-specific date/time | Sets the upper constraint for applicable input types or the upper bound for meter and progress. Format and defaults depend on the element and input type. |
| step | positive number or any | Defines allowed value increments for applicable number and date/time inputs. The step base and default depend on the type and min or value. any disables step mismatch validation. |
| readonly | boolean | Prevents user editing of eligible inputs and textareas without disabling their normal submission. It does not apply to every control type, and scripts can still alter the value. |
| required | boolean | Makes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation. |
| list | datalist ID | Associates a supported input with a datalist of suggestions. It does not restrict the input to the listed values; use select when a closed set is required. |
| placeholder | short text hint | Shows a temporary hint when a supported form field is empty. It disappears during entry and is not a substitute for a persistent accessible label. |
Return Value
HTMLInputElement
Void form-associated element; no child content. The DOM value and form-submission behavior depend on the input state.
Working Example
Example Snippethtml
<label> Tickets <input type="number" name="tickets" min="1" max="8" step="1" value="2"></label>