Open In App

HTML max attribute

Improve
Improve
Like Article
Like
Save
Share
Report

In HTML max attribute it specifies the maximum value of an element. when the max attribute is used by the progress element, it specifies how much work the task requires in the total task. 

Syntax

<element max="value" >

Supported Tags:

The max attribute is used on the following elements:

Name

Description

input max

Maximum value or limit for a parameter or variable.

meter max

The highest possible measurement value on a metering device.

progress max

The maximum level of advancement or completion reached in a process.

HTML max attribute Examples

Example: In this example we demonstrates the use of the max attribute in an input field, limiting the input to multiples of 5 up to a maximum value of 100.

HTML




<!DOCTYPE html>
<html>
    <body>
        <h2>HTML max Attribute in Input Field</h2>
        <form id="myGeeks">
            <input
                type="number"
                id="myNumber"
                step="5"
                name="geeks"
                placeholder="multiples of 5"
                max="100"
            />
        </form>
        <br />
        <br />
        <p style="font-size: 20px">
            The maximum value for an input field
            is 100.
        </p>
    </body>
</html>


Output:

maxAttribute

HTML max attribute Example Output

Example 2: This Example we are using the max attribute within the <progress> tag to indicate a maximum value of 100 for a song download progress bar.

HTML




<!DOCTYPE html>
<html>
    <head>
        <title>max Attribute</title>
    </head>
 
    <body>
        <h2>
            HTML max Attribute used in Progress
            Tag
        </h2>
        Downloading progress for a song:
        <progress value="50"
                  max="100">
        </progress>
    </body>
</html>


Output:

maxAttribute

HTML max attribute example output

Supported Browsers: The browser supported by HTML max Attribute are listed below:



Last Updated : 08 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads