Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <button id="show_all" onclick="show_all()">all</button>
<button id="show_red" onclick="show_red()">red</button>
<button id="show_blue" onclick="show_blue()">blue</button>

<div class="item_wrapper">
<div class="item red" ></div>
<div class="item blue" ></div>
<div class="item red blue"></div>
</div>
              
            
!

CSS

              
                .item{
  width:100px;
  height:100px;
  margin-right:10px;
  margin-bottom:10px;
  display:inline-block;
}
.item.red{
  background:red;
}
.item.blue{
  background:blue;
}
.item.blue.red{
  background:purple;
}
              
            
!

JS

              
                //find all elements tagged "red"
var reds = document.querySelectorAll('.red');

//find all elements tagged "blue"
var blues = document.querySelectorAll('.blue');

//find all elements with "item" class
var alls = document.querySelectorAll('.item');

//function to initially loop through all items and hide them
function hide_init(){
   for (var i = 0; i < alls.length; ++i) { 
 alls[i].style.display = 'none'; 
}
}

function show_red(){  
//call the inital hide function
hide_init();
//loop through red-tagged items and show them  
   for (var i = 0; i < reds.length; ++i) { 
 reds[i].style.display = 'inline-block'; 
} 
}

function show_blue(){  
//call the inital hide function
hide_init();
//loop through blue-tagged items and show them  
   for (var i = 0; i < blues.length; ++i) { 
 blues[i].style.display = 'inline-block'; 
} 
}

function show_all(){  
  //loop through all items and show them
   for (var i = 0; i < alls.length; ++i) { 
 alls[i].style.display = 'inline-block'; 
} 
}
              
            
!
999px

Console