Last Updated : 20 May, 2024
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 <input type="number"></h2>
<form action="#">
<label for="number">Enter Number:</label>
<input type="number" id="number"
value="10" step="5">
</form>
</body>
</html>
Output
Supported BrowsersThe browsers supported by <input type="number"> are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4