YouTip LogoYouTip

Att Input Max

# HTML max Attribute The `max` attribute specifies the maximum value allowed for an `` element. It is commonly used in form validation to restrict user input to a predefined upper limit. --- ## Definition and Usage The `max` attribute defines the upper bound for the input value. When a user enters a value that exceeds this limit, the browser's built-in form validation will prevent form submission and display an error message. * **Tip:** The `max` attribute is often used in conjunction with the [`min`](att_input_min.html) attribute to establish a valid range of values. * **Applicability:** The `max` attribute is compatible with the following `` types: * `number` * `range` * `date` * `datetime-local` * `month` * `time` * `week` --- ## Syntax ```html ``` ### Attribute Values | Value | Description | | :--- | :--- | | `number` | A numeric value. Specifies the maximum allowed number for `number` and `range` input types. | | `date` / `time` | A date, time, or datetime string. Specifies the maximum allowed date/time value (e.g., `YYYY-MM-DD` for dates). | --- ## Code Examples ### Example 1: Restricting Dates and Numbers The following example demonstrates how to use the `min` and `max` attributes to restrict date selections and numeric quantities. ```html






``` --- ## Browser Support The `max` attribute is widely supported in all modern web browsers: * Google Chrome * Microsoft Edge * Mozilla Firefox * Apple Safari * Opera ### Compatibility Notes * **HTML5 Feature:** The `max` attribute is a feature introduced in HTML5. It is not supported in legacy browsers like Internet Explorer 9 and earlier. * **Input Type Support:** While modern browsers support the `max` attribute, ensure that the specific input type (such as `date` or `month`) is also supported by your target browsers for the validation to render correctly.
← Att Input MaxlengthAtt Input List β†’