The <progress> and <meter> tags in HTML5 are used to represent the progress of a task and a scalar measurement within a known range, respectively. While the <progress> tag indicates the completion progress of a task, the <meter> tag represents a measurement, such as disk usage or temperature, within a specified range.
<progress value="25" max="100">25%</progress>
<progress value="50" max="100">50%</progress>
<progress value="100" max="100">100%</progress>
<progress max="100">100%</progress>
<progress value="1.0">50%</progress>
The <meter> tag supports several attributes:
<label for="diskUsage">Disk Usage:</label>
<meter id="diskUsage" min="0" max="100" value="70">70%</meter>
<label for="batteryLevel">Battery Level:</label>
<meter id="batteryLevel" min="0" max="100"
low="20" high="80" optimum="90"
value="50">50%</meter>
The appearance of the <meter> tag can be customized using CSS. However, styling support varies across browsers. Here's an example of how to style the <meter> tag:
meter {
width: 100%;
height: 20px;
}
meter::-webkit-meter-bar {
background: #f4f4f4;
}
meter::-webkit-meter-optimum-value {
background: #2c3e50;
}
meter::-webkit-meter-suboptimum-value {
background: #e6d450;
}
meter::-webkit-meter-even-less-good-value {
background: #f28f68;
}
Note: The above CSS uses vendor-specific pseudo-elements to style the <meter> tag in WebKit-based browsers (e.g., Chrome, Safari). Other browsers may require different approaches.
To ensure the <meter> tag is accessible to all users, including those using screen readers, provide a label that describes the purpose of the meter. Additionally, consider using ARIA attributes to enhance accessibility.
The <meter> tag is a valuable addition in HTML5 for representing scalar measurements within a known range. By understanding its attributes and styling capabilities, we can effectively use it to display various types of data, enhancing the user experience on our web pages.
how Progress bar is managed by JavaScript button Click event
PHP & Ajax is used to update value of a progress bar
Md Shahab Alam | 06-06-2016 |
Thanks Sir,Your Tutorial is very usefull |