Fractional SVG Stars with CSS
Five-star ratings don't have to come in whole stars only. If a widget needs to show a score like 2.25 stars, one approach is to fill the star shapes only partially. That's the technique Samuel Kraft outlines in a post on fractional SVG stars.
The challenge comes at the end of the process, as the source puts it:
The final step is making the overlay div only affect the star SVGs beneath, not the background. We can do this by using the CSS
mix-blend-modeproperty with thecolorvalue.
How the overlay works
The mechanism is an overlay placed on top of the stars. The overlay itself is invisible and leaves the stars untouched, because it is either black or white and uses mix-blend-mode: color;. That combination means the overlay only affects elements that actually carry color. An interactive demo and more detail are available in the original post.
Other routes to the same result
Rating stars have plenty of implementations. Five methods were covered in a prior roundup, and one of them is notably clever: Unicode stars rendered as text, with their background filled using -webkit-background-clip: text;. That lets you partially fill the stars — for instance with a hard-stop linear-gradient().



