Whats the difference between max and maxlength?

Hello, does anybody know why we are taught to write minlength/ maxlength in text areas, when as min/max is understood and renders the same. Is it a better code? Does it render differently in other browsers if it is not written minlength/maxlength in text areas?

thank you

Hello py

Notice that minlenght/maxlength and min/max serve different purposes.

  1. Minlength and maxlength attributes specify the minimum and maximum number of characters allowed in the element.
  2. Min/max attribute specify the minimum and maximum value (we are talking about cyphers here) for an element.

According to w3fools, “the max and min attributes works with the following input types: number, range, date, datetime, datetime-local, month, time and week.”


I don’t still get this… will it still perform the same task of modifying the length of text if used for a text input? if yes then can it be used as a replacement since this is shorter, if no then what can min/max do and where does it work?

I may be late in here, but found this:

max: Valid for date , month , week , time , datetime-local , number , and range , it defines the greatest value in the range of permitted values.
maxlength: Valid for text , search , url , tel , email , and password , it defines the maximum number of characters (as UTF-16 code units) the user can enter into the field.

So as I understand here, max is better used for input types related with numbers.
Correct me if I’m wrong.
Here the link:


Thank you for breaking this down. It makes sense

The minlength and maxlength are are used in terms of character count in an input field.
The max and min attributes are used where the input is in the form of some sort of number.

1 Like