In this short article, I will show you how to display star ratings for your products on your website. You can use the same ratings for your skills on portfolio as well. There are many ways to use the star ratings. I will show you the 5 star ratings example but you can use that for more than 5 star ratings as well, as long as you understand the basics.
Let's start with the basic HTML code.
In the HTML code, all you need is the icons and I am using icons from cloudflare.com. They provided stylesheet link to use any icons which are available in their link. Just go ahead and copy that link.
Now, I've simply added 5 different div elements, you can use span elements as well. The classes I am using aew fa and fa-star, which are from the link we just added. It automatically adds the stars using icons and our most part is done.
Let's take a quick look at the CSS.
In the HTML, you saw that I've added third class in first 3 div elements and that's what I am using here in CSS to style those 3 stars as selected by simply changing their colors.
This is very basic display of the star ratings and I haven't used any CSS style or selectors to make the stars clickable but I am going to do that in the next article. Still, you can use this in PHP as well as Java to get user ratings and set it as final ratings in database and then display it on the website. It's the easiest way to combine those tools.
amazon font awesome ratings