| title | :-webkit-meter-optimum-value | |
|---|---|---|
| slug | Web/CSS/::-webkit-meter-optimum-value | |
| page-type | css-pseudo-element | |
| status |
|
|
| browser-compat | css.selectors.-webkit-meter-optimum-value | |
| sidebar | cssref |
{{Non-standard_header}}
The ::-webkit-meter-optimum-value CSS pseudo-element styles the {{htmlelement("meter")}} element when its value is inside the low-high range, or when the value is equivalent to the optimum value.
Green is the default color.
::-webkit-meter-optimum-value {
/* ... */
}This example will only work in browsers based on WebKit or Blink.
Normal:
<meter min="0" max="10" low="3" high="7" optimum="6" value="6">
Score 6/10
</meter>
<br />
Styled:
<meter id="styled" min="0" max="10" low="3" high="7" optimum="6" value="6">
Score 6/10
</meter>body {
font-family: monospace;
}
.safari meter {
/* Reset the default appearance for Safari only */
/* .safari class is added via JavaScript */
-webkit-appearance: none;
}
#styled::-webkit-meter-optimum-value {
background: linear-gradient(
to bottom,
#77ff77,
#009900 45%,
#009900 55%,
#77ff77
);
height: 100%;
box-sizing: border-box;
}// Safari requires <meter> elements to have an `appearance` of `none` for custom styling
// using `::-webkit-meter-*` selectors, but `appearance: none` breaks rendering on Chrome.
// Therefore, we must check if the browser is Safari-based.
const is_safari =
navigator.userAgent.includes("AppleWebKit/") &&
!navigator.userAgent.includes("Chrome/");
if (is_safari) {
document.body.classList.add("safari");
}{{ EmbedLiveSample('Examples', '100%', 50) }}
Not part of any standard.
{{Compat}}
The pseudo-elements used by WebKit/Blink to style other parts of a {{htmlelement("meter")}} element are as follows:
- {{cssxref("::-webkit-meter-inner-element")}}
- {{cssxref("::-webkit-meter-bar")}}
- {{cssxref("::-webkit-meter-even-less-good-value")}}
- {{cssxref("::-webkit-meter-suboptimum-value")}}