Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

HTML attribute: min

Themin attribute defines the minimum value that is acceptable and valid for the input containing the attribute. If thevalue of the element is less than this, the element failsvalidation. This value must be less than or equal to the value of themax attribute.

Some input types have a default minimum. If the input has no default minimum and a value is specified formin that can't be converted to a valid number (or no minimum value is set), the input has no minimum value.

It is valid for the input types including:date,month,week,time,datetime-local,number andrange types, and the<meter> element.

Syntax

Syntax formin values by inputtype
Input typeSyntaxExample
dateyyyy-mm-dd<input type="date" min="2019-12-25" step="1">
monthyyyy-mm<input type="month" min="2019-12" step="12">
weekyyyy-W##<input type="week" min="2019-W23" step="">
timeHH:mm<input type="time" min="09:00" step="900">
datetime-localyyyy-mm-ddTHH:mm<input type="datetime-local" min="2019-12-25T19:30">
number<number><input type="number" min="0" step="5" max="100">
range<number><input type="range" min="60" step="5" max="100">

Note:When the data entered by the user doesn't adhere to the min value set, the value is considered invalid in constraint validation and will match the:invalid and:out-of-range pseudo-classes.

SeeClient-side validation andrangeUnderflow for more information.

For the<meter> element, themin attribute defines the lower numeric bound of the measured range. This must be less than the maximum value (max attribute), if specified. In both cases, if omitted, the value defaults to 1.

Syntax formin values for other elements
Input typeSyntaxExample
<meter><number><meter min="0" max="100" low="33" high="66" optimum="80" value="40"> at 40/100</meter>

Impact on step

The value ofmin andstep define what are valid values, even if thestep attribute is not included, asstep defaults to0.

We add a big red border around invalid inputs:

css
input:invalid {  border: solid red 3px;}

Then define an input with a minimum value of 7.2, omitting the step attribute, wherein it defaults to 1.

html
<input name="myNumber" type="number" min="7.2" value="8" />

Becausestep defaults to 1, valid values include7.2,8.2,9.2, and so on. The value 8 is not valid. As we included an invalid value, supporting browsers will show the value as invalid.

If not explicitly included,step defaults to 1 fornumber andrange, and 1 unit type (second, week, month, day) for the date/time input types.

Accessibility concerns

Provide instructions to help users understand how to complete the form and use individual form controls. Indicate any required and optional input, data formats, and other relevant information. When using themin attribute, ensure this minimum requirement is understood by the user. Providing instructions within the<label> may be sufficient. If providing instructions outside of labels, which allows more flexible positioning and design, consider usingaria-labelledby oraria-describedby.

Specifications

Specification
HTML
# attr-input-min
HTML
# attr-meter-max

Browser compatibility

html.elements.input.min

html.elements.meter.min

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp