HTML <input type=”number”>

The HTML <input type=”number”> element creates an input field for entering numeric values. It allows for easy input of numbers with optional restrictions such as minimum, maximum, and step values. This element enhances form validation by ensuring only numeric input is accepted, improving user experience and data integrity.

Syntax

<input type="number">

Example: In this example, we will demonstrate the use of HTML <input type=”number”> element.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML input Type Number
    </title>
</head>

<body style="text-align:center;">

    <h2>HTML &lt;input type="number"&gt;</h2>

    <form action="#">
        <label for="number">Enter Number:</label>
        <input type="number" id="number" 
            value="10" step="5">
    </form>
</body>

</html>

Output

Supported Browsers

The browsers supported by <input type=”number”> are listed below:

  • Chrome 7
  • Edge 12
  • Firefox 29
  • Safari 15
  • Opera 5.1

Contact Us