Tutorials References Exercises Menu
Paid Courses

HTML <input type="number">

❮ HTML <input> type attribute


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

type="number" Yes Yes Yes Yes Yes


<input type="number">

❮ HTML <input> type attribute