
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML max Attribute
The max attribute of the <input> element is used to set the maximum value for <input>. Both min and max are used to set a range of value for input element with type number, date, datetime, range, etc. It introduced in HTML5.
Let us now see an example to implement the man attribute of the <input> element. Here, we have set max as 10, therefore a user cannot enter an ID more than 1 −
Example
<!DOCTYPE html> <html> <body> <h2>Log in to your account</h2> <form action="" method="get"> Id − <input type="number" name="id" min="1" max="10"><br> Password − <input type="password" name="pwd"><br> DOB − <input type="date" name="dob" autofocus><br> <button type="submit" value="Submit">Submit</button> </form> </body> </html>
Output
In the above example, we have created a form with some fields and a button −
<form action="" method="get"> Id − <input type="number" name="id" min="1" max="10"><br> Password − <input type="password" name="pwd"><br> DOB − <input type="date" name="dob" autofocus><br> <button type="submit" value="Submit">Submit</button> </form>
The max attribute is set for the id input type number. Max value is set as 10, therefore user won’t be able to enter a value more than 10 −
Id − <input type="number" name="id" min="1" max="10">
- Related Articles
- HTML max Attribute
- HTML max Attribute
- HTML input readonly Attribute
- HTML input value Attribute
- HTML DOM Input Month max Property
- HTML DOM Input Number max Property
- HTML DOM Input Range max property
- HTML DOM Input Date max Property
- HTML DOM Input Datetime max Property
- HTML DOM Input DatetimeLocal max Property
- HTML DOM Input Time max Property
- HTML DOM Input Week max Property
- How to use different step attribute in one range input in HTML?
- HTML pattern Attribute
- HTML novalidate Attribute

Advertisements