Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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.


Save Automatically?

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.


                <p>In the following square you should see a background image that is a URL-encoded SVG, and looks like a heart:</p>

<div class="my-svg-container"></div>

<p class="before-encoding"><b>Input SVG code:</b></p>
<p class="after-encoding"><b>SCSS compiled output after URL-encoding:</b></p>

  <b>Why is this useful?</b>
  You see that the SASS output is longer than the original SVG, and maybe even longer than the Base64-encoded version of it. So why should you use the URL encoded version instead? Check out an article on <a href="" target="_blank"></a>. I've two main reasons why I'm using this compilation step:<br>
  1. Better cross-browser compatibility. There's no need to convert the SVG to a Base64 URL.<br>
  2. DRY principle: Don't repeat yourself. Using my function, I can modify the SVG's style (especially its fill color) by wrapping the code into a function and passing in a parameter (e.g. the fill color). Here's a second SVG with just a different color:

<div class="my-svg-container-2"></div>


 * Author: Kevin Weber
 * Follow me: @kevinweber (
 * Website:
 * License: CC BY-SA 4.0 (

// Add your SVG code here:
@function svg-factory($fill-color) {
  @return '<svg xmlns="" width="24" height="24" viewBox="0 0 24 24"><path fill="' + $fill-color + '" d="M12 4.248c-3.148-5.402-12-3.825-12 2.944 0 4.661 5.571 9.427 12 15.808 6.43-6.381 12-11.147 12-15.808 0-6.792-8.875-8.306-12-2.944z"/></svg>';
$svg-1: svg-factory(#4e97cc);  // Blue
$svg-2: svg-factory(#2c2c29);  // Black

// Thanks to Hugo Giraudel for his str-replace function (
@function str-replace($string, $search, $replace: '') {
  $index: str-index($string, $search);
  @if $index {
    @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
  @return $string;

$encoding-reference: (
  //('%','%25'),  // Encode "%" first, otherwise the "%" from encoded code would be encoded again (which would be bad)
  //('"','%22'),  // Replace " with ' because that's shorter than %22 and normally working
  // Here are a few more characters you could encode
  //(' ','%20'),
  // ('\','%5C'),
  // (' ','%7F'),
  // ('`','%E2%82%AC'),
  //(' ','%C2%A0'),

@function svg-encode($svg) {
  @each $char, $encoded in $encoding-reference {
    $svg: str-replace($svg, $char, $encoded);
  @return 'data:image/svg+xml,' + $svg;

.my-svg-container {
  // HERE you call the svg-encode function and pass in your $svg:
  background-image: url(svg-encode($svg-1));

.my-svg-container-2 {
  background-image: url(svg-encode($svg-2));

// Everything from here and below represents visual sugar. You can ignore it.
body {
  background-color: #f0f0f0;
  margin-left: auto;
  margin-right: auto;
  max-width: 700px;
  padding: 10px;

.my-svg-container-2 {
  background-position: center center;
  background-repeat: no-repeat;
  background-size: 80%;
  border: skyblue 1px solid;
  height: 200px;
  transition: opacity .2s ease-in;
  width: 200px;
  &:hover {
    background-size: 85%;
    opacity: .9;

.after-encoding:after {
  display: block;
  word-break: break-all;

.before-encoding:after {
  content: $svg-1;

.after-encoding:after {
  content: svg-encode($svg-1);