Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <nav role="navigation">
  <ul>
    <li><a href="#the-default-view">the default view</a></li>
    <li><a href="#some-view">some view</a></li>
    <li><a href="#another-view">another view</a></li>
  </ul>
</nav>
<main role="main">
  <div id="some-view">
    <h1>Some view</h1>
    <p>This is one of any number of views that are reachable by linking to its <code>id</code> / hash identifier.</p>
  </div>
  <div id="another-view">
    <h1>Another view</h1>
    <p>This is one of any number of views that are reachable by linking to its <code>id</code> / hash identifier.</p>
  </div>
  <div id="the-default-view">
    <h1>The default view</h1>
    <p>This view is visible by default when the user first arrives at the app.</p>
  </div>
</main>
              
            
!

CSS

              
                /* basic layout */

body {
  font-size: 120%;
  font-family: sans-serif;
  max-width: 40em;
  margin: 0 auto;
}

nav {
  text-align: center;
  padding: 0.5em 0;
  border-bottom: 2px solid;
}

nav li {
  display: inline-block;
  margin: 0 0.5em;
}

/* view visibility logic and animation */

main > * {
  display: none;
}

main > *:last-child {
  display: block;
}

@keyframes pulse {
  0% { transform: scale(1) }
  50% { transform: scale(1.05) }
  100% { transform: scale(1) }
}

main > *:target {
  display: block;
  animation: pulse 0.5s linear 1;
}

main > *:target ~ * {
  display: none;
}
              
            
!

JS

              
                window.addEventListener('hashchange', function() {
	console.log('this view\'s id is', window.location.hash.substr(1));
});
              
            
!
999px

Console