In HTML, the
max attributes are used to set the range of values for the
<input> element. The
min attribute sets the minimum value for the
<input> element, while the
max attribute sets the maximum value for the
We can use the min/max attribute with the following data types:
<input max="number|date"> <input min="number|date">
number: This is used to specify the maximum/minimum number that is allowed.
date: This is used to specify the maximum/minimum date that is allowed.
The basic HTML code to demonstrate the use of the
max attribute is as follows:
In the example above, we can see that we specified the minimum and maximum range between 1 to 50 on line 5 under the “HTML” tab. Hence, we can see in the “Output” tab that the numbers allowed are only between the given range. We can also define the range according to our own choice.
View all Courses