The max
attribute on an element specifies the maximum value that can be entered.
On input elements the max attribute only applies to types that accept numeric, date, or time values.
Elements that accept this attribute include <input>, <meter>, and <progress>.
A max attribute on a number <input> element.
A maximum value that can be entered in this number input is set.
<form action="/tutorial/action.html">
Quantity
<input type="number" name="number" min="1" max="10" value="8">
<br /> <br />
<input type="submit">
</form>
For additional details see our HTML input max Reference.
The max
attribute specifies the maximum value allowed in an element.
On an <input> element, the max
attribute only applies to these types:
<tagname max="number | datetime">
Value | Description |
---|---|
number | The maximum numeric value. |
datetime | The maximum datetime value (for input elements of a certain type only). |
The following elements accept the max
attribute.
Elements | Description | |
---|---|---|
<input> | Specifies an input field -- see example above | |
<meter> | Displays a gauge or scalar measurement within known range. | |
<progress> | Displays progress of task completion. |
A <meter> tag with a max value.
<div>Pressure reading</div>
<br />
<meter min="1" max="25" value="14">14/25</meter>
For additional details see our HTML meter max Reference.
A <progress> tag with a max value.
<div>Loading files... </div>
<br />
<progress id="myprogress" value="0" max="100"></progress>
<script>
setInterval( function(){
let value = document.getElementById("myprogress").value;
value = Math.min(value + .1, 100) % 100;
document.getElementById("myprogress").value = value;
}, 10 );
</script>
For additional details see our HTML progress max Reference.
Here is when max
support started for each browser:
Chrome
|
5.0 | May 2010 |
Firefox
|
16.0 | Oct 2012 |
IE/Edge
|
10.0 | Sep 2012 |
Opera
|
10.6 | Jul 2010 |
Safari
|
5.1 | Oct 2011 |