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 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

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

              
                <h3><code>:nth-child</code>, <code>:nth-last-child</code> ,  <code>:nth-of-type</code> and <code>:nth-last-of-type</code></h3>
<div>
  <button class="child">:nth-child</button>
  <button class="child">:nth-last-child</button>
  <button class="type">b:nth-of-type</button>
  <button class="type">b:nth-last-of-type</button>
</div>
<p>No selector used!</p>
<div class="gel">
  <span>1s</span>
  <b>1b</b>
  <b>2b</b>
  <b>3b</b>
  <span>2s</span>
  <span>3s</span>
  <span>4s</span>
  <i>1i</i>
  <b>4b</b>
  <span>5s</span>
</div>

<h3><code>:first-child</code>, <code>:last-child</code>, <code>:first-of-type</code> and <code>:last-of-type</code></h3>
<div class="eolf">
  <span>1s</span>
  <b>1b</b>
  <b>2b</b>
  <b>3b</b>
  <span>2s</span>
  <span>3s</span>
  <span>4s</span>
  <i>1i</i>
  <b>4b</b>
  <span>5s</span>
</div>

              
            
!

CSS

              
                body {
  font-family: 'Lato';
  font-size: 1.2em;
  text-align: center;
  margin: 20px auto;
}

h3 {
  text-align: left;
  background: pink;
  padding: 5px 10px;
}

h3:nth-child(n+2) {
  margin-top: 80px;
}

span, b, i {
  list-style: none;
  width: 50px;
  height: 35px;
  background: black;
  margin: 3px;
  text-align: center;
  padding-top: 12px;
  color: #FFF;
  border-radius: 3px;
  display:inline-block;
  font-size:0.9em;
  vertical-align: middle;
}

button {
  border: none;
  margin: 2px;
  padding: 8px 14px;
  background: #1DF;
  color: #FFF;
  font-size: 1.1em;
  cursor: pointer;
  font-family: 'Lato';
}

button:hover,
button:active,
button:focus {
  background: #FD1;
}
              
            
!

JS

              
                $(".child").click(function() {
  var selector = $(this).text();
  
  var randomNumberA = Math.ceil(Math.random()*9);
  
  $(".gel span, .gel b, .gel i").css("background-color", "black");
  $("p").text("Selector Used is " + selector + "(" + randomNumberA + ")");
  $(".gel " + selector + "(" + randomNumberA + ")").css("background-color", "#1DF");
});

$(".type").click(function() {
  var selector = $(this).text();
  
  var randomNumberA = Math.ceil(Math.random()*4);
  
  $(".gel span, .gel b, .gel i").css("background-color", "black");
  $("p").text("Selector Used is " + selector + "(" + randomNumberA + ")");
  $(".gel " + selector + "(" + randomNumberA + ")").css("background-color", "#1DF");
});

$("span:first-child").css("border", "4px double brown");
$("span:last-child").css("border", "4px solid crimson");
$("b:first-of-type").css("border", "4px dotted lightgreen");
$("b:last-of-type").css("border", "4px dashed yellow");
$("i:only-of-type").css("background", "orange");

              
            
!
999px

Console