บทนำ
แอตทริบิวต์ min และ max กำหนดค่าต่ำสุดและสูงสุดขององค์ประกอบ ใช้กับ <input>, <meter>, <progress>
องค์ประกอบที่รองรับ
| Element | min | max |
|---|---|---|
<input> | ✓ | ✓ |
<meter> | ✓ | ✓ |
<progress> | - | ✓ |
Input Types ที่รองรับ min/max
number,rangedate,month,week,time,datetime-local
ตัวอย่างโค้ด
<!DOCTYPE html>
<html>
<head>
<title>HTML Min Max Attribute</title>
</head>
<body>
<form action="" method="get">
กรอกตัวเลข 1 ถึง 20: <br>
<input type="number" name="num" min="1" max="20"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Meter และ Progress
<!-- Meter: ค่าที่ทราบ Min/Max (เช่น Disk Usage) -->
<meter min="0" max="100" value="75">75%</meter>
<!-- Progress: ความคืบหน้า (Max required) -->
<progress max="100" value="60">60%</progress>
แอตทริบิวต์เสริมสำหรับ Input
step- ช่วงขั้นvalue- ค่าเริ่มต้น