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>
    <a class="nav-item is-active">
        <!--
            Always render the text bold, but hide it visually and for
            assistive technology.
            This causes the `nav-item` to take up the width that it has
            in its active state.
        -->
        <span style="visibility: hidden; font-weight: bold;">Home</span>
        <!--
            Render a visible label, using absolute positioning and flex
            to position it in the center of the nav-item element.
            This label will change `font-weight` depending on its
            active-state but won't affect layout because it's
            `position: absolute;` It will also never overflow because
            the `nav-item` container already has the largest possible
            width.
        -->
        <span class="label">Home</span>
    </a>
    <a class="nav-item">
        <span style="visibility: hidden; font-weight: bold;">Projects</span>
        <span class="label">Projects</span>
    </a>
    <a class="nav-item">
        <span style="visibility: hidden; font-weight: bold;">Blog</span>
        <span class="label">Blog</span>
    </a>
</nav>
              
            
!

CSS

              
                .nav-item {  
  font-weight: normal;
  position: relative;
}
.nav-item.is-active {
  font-weight: bold;
  background: #ccc;
}

.nav-item .label {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;

  display: inline-flex;
  align-items: center;
  justify-content: center;
}











* {
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-size: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-item {
  font-family: sans-serif;
  cursor: pointer;
  display: inline-block;
  padding: 20px;
}
              
            
!

JS

              
                // A little bit of JavaScript to make
// the items clickable
const anchors = Array.from(document.querySelectorAll('a'))

anchors.forEach(a => {
  a.addEventListener('click', function(e) {
    anchors.forEach(a => {
      a.classList.remove('is-active')
    })

    e.currentTarget.classList.add('is-active')
  })  
})

              
            
!
999px

Console