Horje

How to add HTML <input type="number">

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

Definition and Usage

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

Use the following attributes to specify restrictions:

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


Browser Support

Syntax

<input type="number">

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>Display a Number Field</h1>

<form action="/action_page.php">
  <label for="quantity">Quantity (between 1 and 5):</label>
  <input type="number" id="quantity" name="quantity" min="1" max="5">
  <input type="submit">
</form>

</body>
</html>

Output should be:

How to add HTML <input type="number">




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin