Simple 5-star Rating System with CSS and Html Radios

Category: CSS & CSS3 , Form | December 4, 2014
Views Total: 11,910
Official Page: Go to website
Last Update: December 4, 2014
License: MIT


Simple 5-star Rating System with CSS and Html Radios


A pure CSS solution to create a simple five star rating widget using Html radio inputs and CSS3 transitions/transforms.

How to use it:

Include the required Font Awesome for star icons.

<link rel="stylesheet" href="//">

Create the Html for a five star rating widget using Html radio buttons.

<div class="stars">
  <form action="">
    <input class="star star-5" id="star-5" type="radio" name="star"/>
    <label class="star star-5" for="star-5"></label>
    <input class="star star-4" id="star-4" type="radio" name="star"/>
    <label class="star star-4" for="star-4"></label>
    <input class="star star-3" id="star-3" type="radio" name="star"/>
    <label class="star star-3" for="star-3"></label>
    <input class="star star-2" id="star-2" type="radio" name="star"/>
    <label class="star star-2" for="star-2"></label>
    <input class="star star-1" id="star-1" type="radio" name="star"/>
    <label class="star star-1" for="star-1"></label>

The required CSS/CSS3 styles for the rating widget.

div.stars {
  width: 270px;
  display: inline-block;
} { display: none; } {
  float: right;
  padding: 10px;
  font-size: 36px;
  color: #444;
  transition: all .2s;
} ~ {
  content: '\f005';
  color: #FD4;
  transition: all .25s;
} ~ {
  color: #FE7;
  text-shadow: 0 0 20px #952;
} ~ { color: #F62; } { transform: rotate(-15deg) scale(1.3); } {
  content: '\f006';
  font-family: FontAwesome;
  • Gunther09

    this shit doesnt work

    • Zsolt Füster

      This is working… but i thinked you miss one part:

  • Haplo

    Very nice, thanks for sharing

  • Ashish Rawat

    how will the star rating saved?

    • Asmita

      In the right corner of code u will get 2 link from there u can copy the code and use the code.

  • Swagata Bhattacharyya

    Thanks for sharing this. It works but when the selection seems to be working from the reverse side. e.g. if I select the fourth star it highlights the 4th and 5th in yellow instead of the 1st to 4th. How can I fix it?

  • nik1904

    How do you make this work for multiple stars in a table?

    Example I have a table, where a collum consist of this rating system. Using this code only works for the first rating system. How do I make it work for the rest of them?

    • Sharp

      Wanted to know the same thing.

      From the little that I understand, I don’t think it is possible with this implementation as it meddles with CSS styling, so any changes would influence everything rather than the one thing.

      A shame, since this works amazing, otherwise.

    • Sharp

      Woops, after leaving my initial comment, I soon came to realize that there was in fact a way to do this.

      I used a slightly different variation of this rating system shown by another blog, but it’s almost identical, especially the CSS. Pretty much prepend the ID, Name and For tags with a unique identifier, such as the row ID for the data assigned to the rating.

      Still learning as I go. Hope this helps anyone that came across this like I did.

  • Luis Raúl Clavero Díaz

    muchas gracias!! me sirvió de mucho =D

  • Jx Xiong (jx)

    why not got the star image?

    • Jx Xiong (jx)

      can some one teach me to put the star image in it?

  • Celina Morataya

    So, is this SEO friendly?