Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                
<!-- you may want to start your body element off with a class -->
<input id='toggle' class='toggle' type='checkbox'>
<label for='toggle'><span class='type'></span></label>

<h1>JS Style class toggler thingy</h1>

<p>This is a right of passage.</p>

<p>(but there are many differnet ways to do something like this - that we will talk about later)</p>

              
            
!

CSS

              
                
body {
  font-family: sans-serif;
  color: var(--pe-purple);
  /* some things may be the default stuff like some padding? */
}

body .type::after {
  content: 'new style?';
}



body.hot {
  background-color: var(--pe-red);
  color: var(--pe-yellow);
}

body.hot .type::after {
  content: 'toggle to hot';
}



body.cold {
  background-color: var(--pe-cyan);
  color: var(--pe-blue-dark);
}

body.cold .type::after {
  content: 'toggle to cold';
}


/* one of these could surely be the default - intead of having a neutral to start out with */

              
            
!

JS

              
                
// search the compiled HTML document (document object model) DOM
// understand a few elements
var body = document.querySelector('body');
var toggle = document.querySelector('.toggle');

// define the action
function toggleStyles(event) {
  if (event.target.checked) {
    //alert('checked');
    body.classList.remove('hot');
    body.classList.add('cold');
  } else {
    //alert('not');
    body.classList.remove('cold');
    body.classList.add('hot');
  }
} // a bit naive - because what if there are 30 styles! but totally normal to start the process

// use the action when the toggle is clicked
toggle.addEventListener('click', toggleStyles);

              
            
!
999px

Console