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

              
                <div class="compare">
  <section class="before">
    <small>BALANCED</small>
    <h2 class="balanced">Lorem ipsum, dolor sit amet consectetur adipisicing elit.</h2>
    <p class="balanced">Voluptates incidunt in at cumque quidem. Reiciendis maxime veniam molestias vero quae sequi exercitationem, nemo ullam excepturi dicta unde minus aliquid modi?</p>
    <br>
    <small>PRETTY</small>
    <h2 class="pretty">Tortor id aliquet lectus proin nibh nisl id donec.</h2>
    <p class="pretty">Nec nam aliquam sem et tortor. Non sodales neque sodales ut etiam sit amet. Enim lobortis scelerisque fermentum dui faucibus in ornare quam. Quis risus sed vulputate odio ut enim blandit volutpat maecenas condimentum.</p>
  </section>
  <section class="after">
    <small>NOT BALANCED</small>
    <h2>Lorem ipsum, dolor sit amet consectetur elit.</h2>
    <p>Voluptates incidunt in at cumque quidem. Reiciendis maxime veniam molestias vero quae sequi exercitationem, nemo ullam excepturi dicta unde minus aliquid modi?</p>
    <br>
    <small>NOT PRETTY</small>
    <h2>Tortor id aliquet lectus proin nibh nisl id donec.</h2>
    <p>Nec nam aliquam sem et tortor. Non sodales neque sodales ut etiam sit amet. Enim lobortis scelerisque fermentum dui faucibus in ornare quam. Quis risus sed vulputate odio ut enim blandit volutpat maecenas condimentum.</p>
  </section>
  <input type="range" id="range">
</div>
              
            
!

CSS

              
                @layer demo {
  .balanced {
    text-wrap: balance;
  }
  
  .pretty {
    text-wrap: pretty;
  }
  
  h2, p {
    max-inline-size: 30rem;
  }
}

@layer demo.support {
  * {
    box-sizing: border-box;
    margin: 0;
  }

  html {
    block-size: 100%;
    color-scheme: dark light;
  }

  body {
    min-block-size: 100%;
    font-family: system-ui, sans-serif;
    display: grid;
  }
  
  p {
    font-size: 1.25rem;
    line-height: 1.5;
  }
  
  .compare {
    display: grid;
    
    > * {
      grid-area: 1 / 1;
    }
    
    > section {
      display: grid;
      place-content: center;
      gap: 2ch;
    }
  }
  
  .before {
    mask: linear-gradient(to right, #000 0, var(--pos, 50%), #0000 0);
  }
  
  .after {
    mask: linear-gradient(to right, #0000 0, var(--pos, 50%), #000 0);
  }
  
  input[type="range"] {
    z-index: 1;
    appearance: none;
    background: transparent;
    cursor: pointer;
    
    &::-webkit-slider-thumb {
      appearance: none;
      width: 4px;
      height: 100dvh;
      background-color: hotpink;
    }
  }
  
  small {
    border-radius: 50px;
    border: 1px solid LinkText;
    max-inline-size: max-content;
    padding-inline: 1ch;
    padding-block: .25ch;
  }
}
              
            
!

JS

              
                range.oninput = () =>
  document.body.style.setProperty('--pos', range.value + '%')

              
            
!
999px

Console