Star Ratings in CSS and HTML

Looking to add star ratings to your web articles without image sprites? Here’s a sample CSS snippet that uses Data URIs to insert images as seen on the Chrome website.

CSS Star Ratings

That’s the basic CSS style. The .rating class properly aligns the individual stars while the .star and .unstar classes render the stars. For example, if you are display a rating of 3.5 out of 5 stars, the corresponding HTML code would be: