Create a simple and elegant 5-star rating system with HTML radio buttons and CSS

Category: CSS & CSS3 Form JavaScript/jQuery Plugins | September 3, 2021
Author: jexordexan
Official Page: Go to website
Last Update: September 3, 2021
License: MIT


I was searching for the code, by using that I can create a simple 5-star rating system with HTML radio buttons and pure CSS. I came across this example which is created by Jordan-Simonds on codepen, which helped me a lot. So, I thought I should share this tool with someone who is interested in creating a 5-star rating system with HTML radio button and pure CSS style.

How can I use it?

The basic requirement for this is to add Font Awesome for star icons. Put following under <HEAD> tag.

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

And, then structure your radio elements like this:

<div class="cont">
<div class="title">
<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>

Now, add the CSS like this:

@import url(,100,300,700,400);
  margin: 0;
  padding: 0;
  font-family: roboto;
  background: #000;
  width: 93%;
  max-width: 350px;
  text-align: center;
  margin: 4% auto;
  padding: 30px 0;
  background: #111;
  color: #EEE;
  border-radius: 5px;
  border: thin solid #444;
  overflow: hidden;
  margin: 20px;
  border: none;
  border-bottom: thin solid rgba(255,255,255,.1);
  font-size: 2em;
h1 span{
  font-weight: 300;
  color: #Fd4;
  width: 270px;
  display: inline-block;
  display: none;
} {
  float: right;
  padding: 10px;
  font-size: 36px;
  color: #444;
  transition: all .2s;
} ~ {
  color: #FD4;
  transition: all .25s;
} ~ {
  text-shadow: 0 0 20px #952;
} ~ {
  color: #F62;
  transform: rotate(-15deg) scale(1.3);
  font-family: FontAwesome;
  overflow: hidden;
  height: 0;
  width: 100%;
  transition: all .25s;
  background: #222;
  border: none;
  width: 100%;
  max-width: 100%;
  height: 100px;
  padding: 10px;
  box-sizing: border-box;
  color: #EEE;
  display: block;
  transition:opacity .25s;
} ~ .rev-box{
  height: 125px;
  overflow: visible;