Styling a Range Input
suggest changeStart with the native control and use accent-color for a portable theme:
<label>
Volume
<input type="range" min="0" max="100" value="50">
</label>
input[type="range"] {
inline-size: min(100%, 24rem);
accent-color: rebeccapurple;
}
Fully replacing the track and thumb still requires engine-specific pseudo-elements such as ::-webkit-slider-thumb and ::-moz-range-thumb; there is not yet one interoperable standard pseudo-element for every range part. Prefer the native control unless the design genuinely requires a custom appearance.
When customizing it:
- preserve a visible
:focus-visibleindicator; - keep the thumb large enough for touch input;
- maintain sufficient contrast in forced-colors mode;
- test keyboard input, vertical writing modes, zoom, and right-to-left direction;
- retain the input's accessible label and native semantics.
Avoid the obsolete ::-ms-* selectors, which targeted legacy Internet Explorer.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents