Hi,
As I was reading through the article Other form controls and on the section Progress and meter they explained the different attributes used with <meter>
element.
With the optimum
attribute everything works as expected like <meter>
changes color from green to yellow and then red based on the different attribute values. Confusing arises when the optimum
attribute is not present for example:
<meter id="fuel" min="0" max="100" low="33" high="66" value="25">25</meter>
According to the <meter>
: The HTML Meter element page they says, the low
attribute Specifies the range that is considered to be a low value and it must be between min
and max
attribute values which it is. So we should expect the color of this meter to be red because it is in the lower part of the range but it is not red it is yellow as the value
which is 25 is between min
and low
.
Similarly, if we change the value to 75 which is higher than the high
value it should be red but again it is yellow. I thought maybe without the optimum
attribute it is behaving differently but then I found an example on the MDN meter page the example is:
He got a <meter low="69" high="80" max="100" value="84">B</meter> on the exam.
Here there is no optimum
attribute present but the <meter>
seems to work as expected the color is red but why is this working and the above example is not after digging into the example I found if we set the low
value greater than 50 like 51 then it will work as expected I donât know why this is happening maybe there is a default value for optimum
attribute I donât know that is where I hoping to get an explanation.
Thank you.