How to create a simple "star rating" look with CSS?

CSSWeb DevelopmentFront End Technology

To create a simple star rating look with CSS, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      margin: 30px;
   }
   .fa {
      font-size: 30px;
      color: grey;
   }
   .rated {
      color: rgb(255, 0, 0);
      border: 2px solid yellow;
   }
</style>
</head>
<body>
<h1>Star Rating Example</h1>
<span class="fa fa-star rated"></span>
<span class="fa fa-star rated"></span>
<span class="fa fa-star rated"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 07-May-2020 15:09:55
Advertisements