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.


                <!-- This first example has its content defined in JavaScript -->
<js-description header="Web Components 101">I have been working on figuring out <a href="">web components</a>. This explanitory text is an example of the kind of thing that you can do. Below is another example of what you can do.</js-description>

<!-- This second example has it's content defined in a template -->
<template id="gravatarTemplate">
<js-gravatar email=""></js-gravatar>




                // ** For the intro example **
// Create MyComponent
class MyComponent extends HTMLElement {
  connectedCallback() {
    // What content goes into MyComponent?
    this.innerHTML = `<h1>`+this.getAttribute("header")+`</h1><p>`+this.innerHTML+`</p>`;
// Attach MyComponent to js-description
customElements.define('js-description', MyComponent);

// ** For the gravitar example **
// Gravatar needs an MD5 hash of the email, so we are using a 3rd party library for that
function updateImg(img, email) {
    img.setAttribute("src", "//" + SparkMD5.hash(email));

var gravatarElementPrototype = Object.create(HTMLElement.prototype);
gravatarElementPrototype.attributeChangedCallback = function (attributeName, oldVal, newVal) {
    if (attributeName == "email") {
			// this.shadowRoot is the root node of a DOM subtree that is rendered separately from a document's main DOM tree        
			updateImg(this.shadowRoot.querySelector('img'), newVal);
gravatarElementPrototype.createdCallback = function () {
    var t = document.querySelector('#gravatarTemplate');
    var clone = document.importNode(t.content, true);
    updateImg(clone.querySelector('img'), this.getAttribute("email") || "");

var MyGravatarElement = document.registerElement('js-gravatar', {
    prototype: gravatarElementPrototype