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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

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


                <h1>Folding tutorial concept</h1>
<button id="toggle" class="fa-eye-slash"></button>

<div class="instructions">
  <h2>Self-invoking anonymous functions</h2>
  <p>Since we don't want to pollute the global namespace, we're going to encapsulate our demo within a self-invoking anonymous function. It starts like this:</p>
<div class="code">
  <pre><code class="language-javascript">;(function () {</code></pre>
<div class="instructions">
  <p>Note that we've added a <code class="language-javascript">;</code> at the beginning of the line. This is in case our file gets concatinated with something that didn't end with a semicolon.</p>
  <p>From here, we can include our function body. Let's write fizzbuzz.</p>
<div class="code">
  <pre><code class="language-javascript">    //fizzbuzz
    for (var i = 1; i <= 100; i++) {
        if (i % 15 === 0) {
        } else if (i % 3 === 0) {
        } else if (i % 5 === 0) {
        } else {
<div class="instructions">
  <p>This function prints 1 to 100 with "fizz" taking the place of any multiple of 3, "buzz" taking the place of any multiple of 5, and "fizzbuzz" taking the place of any multiple of both 3 and 5.</p>
  <p>Now that our function is defined, all we need to do is call it.</p>
<div class="code">
  <pre><code class="language-javascript">})();</code></pre>
  <p>Demo brought to you by <a href="" target="_blank">rileyjshaw</a>.</p>
<script src=//></script>



  overflow-y: scroll
  margin: 1.5em auto 0
  font: 27px 'Slabo 27px', serif
  color: #333
h1, .instructions, pre, footer
  width: 600px
  margin: auto

  margin-bottom: .5em
  margin-top: 0
h1, .instructions, footer
  max-width: 94%
  overflow: hidden
  max-height: 400px
  transition: max-height 0.9s, opacity 0.3s 0.3s
  .instructions-hidden &
    max-height: 0
    opacity: 0
    transition: max-height 0.9s, opacity 0.3s

  font-size: 24px
  background: #002b36
  position: fixed
  right: 12px
  bottom: 12px
  height: 48px
  width: 48px
  border: 0
  outline: 0
  font: 22px Fontawesome
  border-radius: 24px
  cursor: pointer
  color: #fff
  background: #ff6f00
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3)



                function toggleClass (el, className) {
  if (el.classList) {
  } else {
    var classes = el.className.split(' ');
    var existingIndex = classes.indexOf(className);

    if (existingIndex >= 0)
      classes.splice(existingIndex, 1);

    el.className = classes.join(' ');

var body = document.body;
var toggle = document.getElementById('toggle');

toggle.addEventListener('click', function () {
  toggleClass(body, 'instructions-hidden');
  toggleClass(toggle, 'fa-eye');
  toggleClass(toggle, 'fa-eye-slash');
}, false);