cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="tabs">
  <div class="links">
    <a href="" data-tab="1">Tab 1</a>
    <a href="" data-tab="2">Tab 2</a>
    <a href="" data-tab="3">Tab 3</a>
    <a href="" data-tab="4">Tab 4</a>
  </div>
    <div data-content="1" data-tab-active>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam porro ipsum dolores, soluta repudiandae vel, fugiat commodi architecto magni nesciunt neque eum eius aliquid maiores officiis beatae nisi quia itaque.</div>
    <div data-content="2">Content 2</div>
    <div data-content="3">Content 3</div>
    <div data-content="4">Content 4</div>
</div>
            
          
!
            
              body {
  margin: 10px;
}

.links {
    margin-bottom: 10px;
}
.tabs div[data-content] {
    display: none;
}
.tabs div[data-tab-active] {
    display: inherit;
}
            
          
!
            
              var Module = (function () {
    
    var scope, slice = Array.prototype.slice;
    
    function showTab (event) {
        var attr = this.getAttribute('data-tab');
        var items = slice.call(scope.querySelectorAll('[data-content]'));
        items.forEach(function (item) {
            item[(item.getAttribute('data-content') === attr ? 'set' : 'remove') + 'Attribute']('data-tab-active', true);
        });
        event.preventDefault();
    }

    return function (elems) {
        scope = document.querySelector(elems);
        var tabs = slice.call(document.querySelectorAll(elems + ' [data-tab]'));
        tabs.forEach(function (tab) {
            tab.addEventListener('click', showTab);
        });
    };
    
})();

Module('.tabs');
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console