Pen Settings



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


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.


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.


                <h1>Using an Anchor as a Button</h1>

<a href="#" class="button js-button" role="button">Show content</a>

<div class="content">
  <p>This demonstrates how to markup an <code>&lt;anchor&gt;</code> element as if it were a <code>&lt;button&gt;</code> element.</p>
  <p>Key takeaway is to add <code>role="button"</code> and handle the 'space' key as native buttons will excecute JS events on 'space' keypress by default.</p>


                .button {
  background-color: Crimson;  
  border-radius: 5px;
  color: white;
  padding: .5em;
  text-decoration: none;

.button:hover {
  background-color: FireBrick;
  color: White;

.content {
  display: none;
  margin: 1em 0;
.no-js .content {
  display: block;


                (function (document, window, undefined) {
  'use strict';
  // Buttons
  var buttons = document.querySelectorAll('.js-button');   
  var displayContent = function (button, content) {
    if (content.classList.contains('active')) {
        // Hide content
        button.setAttribute('aria-expanded', 'false');
        content.setAttribute('aria-hidden', 'true');
      } else {
        // Show content
        button.setAttribute('aria-expanded', 'true');
        content.setAttribute('aria-hidden', 'false');
  [], function(button, index) {
    // Content var
    var content = button.nextElementSibling;
    // Set button attributes
    button.setAttribute('id', 'button-' + index);
    button.setAttribute('aria-expanded', 'false');
    button.setAttribute('aria-controls', 'content-' + index);
    // Set content attributes
    content.setAttribute('id', 'content-' + index);
    content.setAttribute('aria-hidden', 'true');    
    content.setAttribute('aria-labelledby', 'button-' + index);
    button.addEventListener('click', function () {
      displayContent(this, content);
      return false;
    }, false);
    button.addEventListener('keydown', function (event) {
      // Handle 'space' key
      if (event.which === 32) {
        displayContent(this, content);
    }, false);
})(document, window);