Tag meter

The meter tag is a semantic HTML5 element used to display a scalar measurement within a known range, such as scoresdisk usagebattery level, or progress toward a goal. It’s ideal for showing values with meaning, unlike <progress>, which only tracks completion.


📌 What Is the <meter> Tag?

The <meter> element represents a numeric value between a minimum and maximum. It provides a visual bar and can include optional thresholds for lowhigh, and optimum values.


🧪 Basic Example

<label for="disk">Disk usage:</label>
<meter id="disk" value="0.7">70%</meter>

💾 This displays a bar filled to 70% to show current disk usage.


⚙️ Key Attributes

AttributeDescriptionExample
valueCurrent value (required)value="0.7"
minMinimum value (default is 0)min="0"
maxMaximum value (default is 1)max="1"
lowLower limit of optimal rangelow="0.3"
highUpper limit of optimal rangehigh="0.9"
optimumBest/ideal valueoptimum="0.5"

📷 Advanced Example with Visual Thresholds

<label for="battery">Battery level:</label>
<meter id="battery" value="0.2" min="0" max="1" low="0.25" high="0.75" optimum="1">
20%
</meter>

🔋 In this example:

  • Below 0.25 → Low (usually rendered in red)
  • Between 0.25 and 0.75 → Normal
  • Above 0.75 → High
  • Optimum is 1 (full battery)

💡 Browsers may style the bar differently based on these values.


🧩 Structure Diagram

php-templateCopyEdit<label>Text</label>
<meter value="X" min="A" max="B" low="L" high="H" optimum="O">Optional Text</meter>

🎯 Use Cases for <meter>

Use CaseDescription
✔️ Battery levelShow charge percentage
✔️ Score displayExam/test scores out of 100
✔️ Quota usageCloud storage, data plan, disk space
✔️ Performance gaugeCPU usage or web vitals

🖌️ Styling the <meter> Tag

The <meter> element is natively styled by browsers, but you can apply CSS:

meter::-webkit-meter-bar {
background: #eee;
}
meter::-webkit-meter-optimum-value {
background: green;
}
meter::-webkit-meter-suboptimum-value {
background: orange;
}
meter::-webkit-meter-even-less-good-value {
background: red;
}

⚠️ Full styling support is limited and vendor-prefixed.


🚫 Don’t Confuse With <progress>

TagPurposeExample Use
<meter>Displays a value within a rangeBattery, score
<progress>Shows task completion (0–100%)File upload

✅ Accessibility Tips

  • Always use <label for="id"> to describe the meter.
  • Provide text inside <meter> for screen readers (Battery: 20%).
  • Make sure color is not the only indicator of status.

✅ Conclusion

The <meter> tag is a clean, semantic way to show values within a known range. It’s perfect for scores, capacities, and thresholds where users need to visually interpret numeric data. While styling is somewhat limited, its semantic value and accessibility make it a smart choice in many UI situations.