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

              
                <main class="parent">
  
  <!-- .sister immediately after .brother -->
  <div class="brother"><code>.brother</code></div>
  <div class="sister"><code>.sister</code></div>

  <!-- .sister immediately after .brother -->
  <div class="brother"><code>.brother</code></div>
  <div class="sister"><code>.sister</code></div>
  <!-- .sister immediately after .sister -->
  <div class="sister"><code>.sister</code></div>

  <div class="brother"></div>
  <!-- .cousin immediately after .brother -->
  <div class="cousin">
    <!-- .sister contained in a .cousin -->
    <code>.cousin</code>
    <div class="sister"><code>.sister</code></div>
  </div>
</main>
              
            
!

CSS

              
                /* Select all div elements */
div {
  background: hsl(0 0% 0% / .5);
  border: 1px solid white;
  color: white;
  place-items: center;
  padding-block: 1rem;
  padding-inline: 1.5rem;
  position: relative;
  width: 100%;
}

/* Selects all .brother elements */
.brother {
  background-color: hsl(25 100% 50%);
}

/* Selects all .sister elements */
.sister {
  background-color: hsl(150 50% 30%);
}

/* Select .sister if it comes after .brother and shares the same parent */
.brother ~ .sister {
  background-color: hsl(250 50% 30%);
}

/* Select .sister if it comes after .brother and shares the same parent */
.brother + .sister {
  background-color: hsl(350 50% 30%);
}

@layer base {
  html {
    background-color: #262626;
    background-position: top center;
    background-repeat: no-repeat;
    background-image:
      radial-gradient(50% 50% at top center, rgb(0 0 0 / 0.66), #262626),
      linear-gradient(180deg, #fff, #262626);
    background-size: 120% 2000px, 100% 2000px;
  }
  
  body {
    display: grid;
    font-size: 1.5rem;
    gap: 1.5rem;
    font-family: Merriweather, serif;
    padding: 1ch;
  }
  
  main {
    display: grid;
    gap: 1rem;
  }
  
  div > div {
    inset-block-start: 1rem;
    inset-inline-start 100vw;
    position: absolute;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console