New in HTML5.

<input max="">

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
Attribute of
How To Use Input To Create Form Fields In HTML: Easy Tutorial
What does <input max=""> do?
Specifies a maximum value for number and date input fields.

Code Example

 <label for="hours">How many hours are you available to work each week?</label><br>
 <input type="number" id="hours" name="hours" max="168">

<!-- Try putting in 170 and pressing enter. -->

The max attribute and data validation

Specifying a max attribute on an <input> element allows you to put an upper limit on certain types of inputs ‘number’ and ‘date’. The form will not accept any inputs higher than the max value. However, that does not absolve you (the developer) of proper form validation. For one thing, a browser that doesn’t support the max attribute will still allow a user to enter an invalidly high value. More importantly, though, it is (almost) always possible for a malicious user to submit data to your server directly, bypassing the HTML form altogether. (This can happen for any form field.) So, using the max attribute to limit the value of numerical or date-based inputs can help usability a little bit, but don’t rely on it if a too-high value would cause problems on when submitted to the server.

Adam is a technical writer who specializes in developer documentation and tutorials.

Browser Support for max