Form

Number input

Published on

Description Link to section description

The number input accepts numeric values. It includes browser-provided increment/decrement controls and restricts input to digits on mobile keyboards.

Example Link to section example

Open in new tab(opens in new tab)
View HTML markup
<form method="POST" novalidate="">
  <div><label for="number"> Number</label> <span id="number-hint">Should be prime and greater than 99</span> <input value="" id="number" name="number" type="number" size="3" aria-describedby="number-hint" /> </div> <button type="button">Submit</button>
  <p>Need help? <a href="/form/input-number" target="_top">View our guidance</a></p>
</form>

Accessibility Link to section accessibility

  • Use explicit <label for="id"> association.
  • Inherit typography for WCAG 1.4.12 compliance.
  • The increment/decrement spinner buttons can be difficult for some users. Consider a plain text input with inputmode="numeric" and pattern="[0-9]*" for simpler numeric entry.
  • Associate min, max, and step constraints via hint text using aria-describedby.

References Link to section references

Variables Link to section variables

None for input