Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML max Attribute

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>.

Example

#

A max attribute on a number <input> element.
A maximum value that can be entered in this number input is set.

Quantity  

<form action="/tutorial/action.html">
  Quantity &nbsp;
  <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.


Using max

The max attribute specifies the maximum value allowed in an element.

On an <input> element, the max attribute only applies to these types:


Syntax

<tagname max="number | datetime">

Values

#

Value Description
number The maximum numeric value.
datetime The maximum datetime value (for input elements of a certain type only).

Elements that accept max

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.

<meter> with max

A <meter> tag with a max value.

Pressure reading

14/25
<div>Pressure reading</div>

<br />
<meter min="1" max="25" value="14">14/25</meter>

For additional details see our HTML meter max Reference.


<progress> with max

A <progress> tag with a max value.

Loading files...

<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.


Browser support

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

You may also like




Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides