Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML <input type="number">

❮ HTML <input> type attribute

Example

Define a field for entering a number (You can also set restrictions on what numbers are accepted):

<label for="quantity">Quantity (between 1 and 5):</label>
<input type="number" id="quantity" name="quantity" min="1" max="5">
Try it Yourself »

Definition and Usage

The <input type="number"> defines a field for entering a number.

Use the following attributes to specify restrictions:

  • max - specifies the maximum value allowed
  • min - specifies the minimum value allowed
  • step - specifies the legal number intervals
  • value - Specifies the default value

Tip: Always add the <label> tag for best accessibility practices!  


Browser Support

Attribute
type="number" Yes Yes Yes Yes Yes

Syntax

<input type="number">

❮ HTML <input> type attribute