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="container">
  <div class="content">
<!--     note this only works if the text content matches the cover color -->
    <code id="lorem"></code>
    <div class="block"></div>
  </div>
</div>
<div class="the-curtain">
  <input id="toggle" type="checkbox" />
  <label for="toggle">pull back the curtain</label>
</div>
              
            
!

CSS

              
                :root {
  --background: whitesmoke;
  --covers: var(--background);
  --edges: silver;
  font-family: sans-serif;
}

.the-curtain {
  padding: 8px;
}

@supports not selector(:has()) {
  .the-curtain > * {
    display: none;
  }
  
  .the-curtain:after {
    opacity: 1;
    font-style: italic;
    font-size: 8px;
    content: 'I guess you guys aren\'t ready for :has() yet. The junior devs are gonna love it.';
  }
}

.container:has(+ div > #toggle:checked) {
  --covers: red;
  --edges: green;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  flex-direction: column;
}

.container {
  width: 1000px;
  overflow: auto;
  background: var(--background);   
  background-image: 
    linear-gradient(to right, var(--covers) 8px, transparent 8px), 
    linear-gradient(to left, var(--covers) 8px, transparent 8px), 
    linear-gradient(to left, var(--edges) 0px, transparent 8px), 
    linear-gradient(to right, var(--edges) 0px, transparent 8px);
  background-attachment: local, local, scroll, scroll;
}

/*pro-tip: use side columns to hide clipping */

#lorem {
  font-size: 32px;
  white-space: pre;
}

.content {
  padding: 10px;
}


.block {
  display: inline-block;
  height: 40px;
  width: 40px;
  background: white;
  border: 1px solid black;
}
              
            
!

JS

              
                document.getElementById('lorem').innerText = `Lorem Ipsum \n\nis simply dummy text of \n\nthe printing and typesetting industry. Lorem Ipsum has been the\n industry's standard dummy text ever since the 1500s, when an unknown\n printer took a galley of type and scrambled it to make a type \n\nspecimen book.\n\nIt has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.\n\n It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\n\n`;


              
            
!
999px

Console