Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!-- An interactive CSS star rating component.

Has hover and selected states, and could be integrated into a form very easily (as underneath the visual styling it is just radio buttons).  Size and margin between the stars can be easily changed by amending the sass variables.

No JS, all CSS and HTML.

Works on IE9>, Chrome, Firefox, Safari

<div class="container">
  <h1>Interactive Star Rating Component (CSS Only) <a href="" target="blank">created by @AshNolan_</a></h1>
  <div class="demo">
    <div class="ratingControl">
        <input type="radio" id="rating-5" name="rating" value="5">
        <label class="ratingControl-stars ratingControl-stars--5" for="rating-5">5</label>
        <input type="radio" id="rating-45" name="rating" value="4.5">
        <label class="ratingControl-stars ratingControl-stars--45 ratingControl-stars--half" for="rating-45">45</label>
        <input type="radio" id="rating-4" name="rating" value="4">
        <label class="ratingControl-stars ratingControl-stars--4" for="rating-4">4</label>
        <input type="radio" id="rating-35" name="rating" value="3.5">
        <label class="ratingControl-stars ratingControl-stars--35 ratingControl-stars--half" for="rating-35">35</label>
        <input type="radio" id="rating-3" name="rating" value="3">
        <label class="ratingControl-stars ratingControl-stars--3" for="rating-3">3</label>
        <input type="radio" id="rating-25" name="rating" value="2.5">
        <label class="ratingControl-stars ratingControl-stars--25 ratingControl-stars--half" for="rating-25">25</label>
        <input type="radio" id="rating-2" name="rating" value="2">
        <label class="ratingControl-stars ratingControl-stars--2" for="rating-2">2</label>
        <input type="radio" id="rating-15" name="rating" value="1.5">
        <label class="ratingControl-stars ratingControl-stars--15 ratingControl-stars--half" for="rating-15">15</label>
        <input type="radio" id="rating-1" name="rating" value="1">
        <label class="ratingControl-stars ratingControl-stars--1" for="rating-1">1</label>
        <input type="radio" id="rating-05" name="rating" value="0.5">
        <label class="ratingControl-stars ratingControl-stars--05 ratingControl-stars--half" for="rating-05">05</label>


$ratingControl-star-size: 65px;
$ratingControl-star-margin: 10px;

$ratingControl-star-width: $ratingControl-star-size + $ratingControl-star-margin; // width takes into account the size and the margin, as this makes the label wider based on these two values
$ratingControl-star-count : 5;

$icon-path: '';

// SVG datauris used for the stars to avoid loading flash when interacted with
$icon-star: 'data:image/svg+xml;charset=US-ASCII,';
$icon-star--filled: 'data:image/svg+xml;charset=US-ASCII,';
$icon-star--light: 'data:image/svg+xml;charset=US-ASCII,';

.ratingControl {
    position: relative;
    width: $ratingControl-star-width * $ratingControl-star-count;
    height: $ratingControl-star-size;
    user-select: none;
    margin: 0 auto;

    input {
        visibility: hidden;
    .ratingControl-stars {
        position: absolute;
        top: 0;
        width: $ratingControl-star-width;
        height: $ratingControl-star-size;
        background-image: url($icon-star);
        // uses datauri, but image is actually being pulled from here: '#{$icon-path}/star--empty.svg';
        background-size: auto $ratingControl-star-size;
        background-repeat: no-repeat;
        cursor: pointer;

        text-indent: 100%;
        white-space: nowrap;
        overflow: hidden;

        // hover effect applied to the hovered star and all preceeding stars (and if the radio button is checked)
        .ratingControl-stars:hover ~ &,
        input:checked ~ & {
            background-image: url($icon-star--filled);
            // uses datauri, but image is actually being pulled from here: #{$icon-path}/star--filled.svg

        // displays a slightly different coloured star when someone is actively clicking the item
        .ratingControl-stars:active ~ &,
        input:checked ~ &:active {
            background-image: url($icon-star--light);       
              // uses datauri, but image is actually being pulled from here: #{$icon-path}/star--filled--light.svg
        .ratingControl-stars--05 { left: $ratingControl-star-width * 0; }
        .ratingControl-stars--1  { left: $ratingControl-star-width * 0; }
        .ratingControl-stars--15 { left: $ratingControl-star-width * 1; }
        .ratingControl-stars--2  { left: $ratingControl-star-width * 1; }
        .ratingControl-stars--25 { left: $ratingControl-star-width * 2; }
        .ratingControl-stars--3  { left: $ratingControl-star-width * 2; }
        .ratingControl-stars--35 { left: $ratingControl-star-width * 3; }
        .ratingControl-stars--4  { left: $ratingControl-star-width * 3; }
        .ratingControl-stars--45 { left: $ratingControl-star-width * 4; }
        .ratingControl-stars--5  { left: $ratingControl-star-width * 4; }

    .ratingControl-stars--half {
        width: ceil($ratingControl-star-size / 2) + 1;

// Define the fonts used in the Pen
@import url(;
@import url(;

@font-face {
  font-family: 'Audiowide';
  font-style: normal;
  font-weight: 400;
  src: local('Audiowide'), local('Audiowide-Regular'), url( format('woff');

$color-bg: #fff; //background for the demo

body {
	font-size: 62.5%;
	background-color: $color-bg;
  margin: 10px;
  border: 1px solid #333;

h1, h2, h3 {
	font-family: 'PT Sans', sans-serif;
	text-transform: uppercase;

h1 {
  font-size: 2.4em;
  background-color: rgba(41, 41, 41, 1);
  text-align: center;
  padding: 20px;
  margin: 0;
  color: #fff;
  a {
    display: block;
    margin-top: 10px;
    text-transform: none;
    color: #aaa;
    font-size: 16px;
    text-decoration: none;

.demo {
  padding: 40px;