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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <!-- Some Page Content -->
<main>
  <h1>Dialog Demo</h1>
  <h2>Scroll to open dialog.</h2>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto recusandae amet, rerum quasi quaerat ipsum nam earum vitae distinctio deleniti. Rerum earum excepturi ab, totam tenetur fuga praesentium illum repudiandae.</p>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto recusandae amet, rerum quasi quaerat ipsum nam earum vitae distinctio deleniti. Rerum earum excepturi ab, totam tenetur fuga praesentium illum repudiandae.</p>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto recusandae amet, rerum quasi quaerat ipsum nam earum vitae distinctio deleniti. Rerum earum excepturi ab, totam tenetur fuga praesentium illum repudiandae.</p>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto recusandae amet, rerum quasi quaerat ipsum nam earum vitae distinctio deleniti. Rerum earum excepturi ab, totam tenetur fuga praesentium illum repudiandae.</p>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto recusandae amet, rerum quasi quaerat ipsum nam earum vitae distinctio deleniti. Rerum earum excepturi ab, totam tenetur fuga praesentium illum repudiandae.</p>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto recusandae amet, rerum quasi quaerat ipsum nam earum vitae distinctio deleniti. Rerum earum excepturi ab, totam tenetur fuga praesentium illum repudiandae.</p>
  
  
  <!-- Dialog Button -->
  <button onclick="window.dialog.showModal();">Open Dialog</button>
</main>

<!-- Dialog Popup Itself -->
<dialog id="dialog">
  <h2>Hello.</h2>
  <p>I'm a dialog element that is open. You can close me by clicking on the "x" which is my close button. I am also styled in CSS, and can accept arbitrary content. I will remain fixed to the center of the window by default as you scroll the page.</p>
  <p>I also have a <code>::backdrop</code> you can style, which lives between me and the page.</p>
  <button onclick="window.dialog.close();" aria-label="close" class="x">❌</button>
</dialog>
              
            
!

CSS

              
                :root {
  --page-accent: rgb(241, 212, 252);
}

// Style backdrop of dialog

dialog::backdrop {
  background: linear-gradient(
    to top,
    rgba(200, 210, 250, 0.8),
    rgba(10, 150, 130, 0.8),
  )
}

// Style dialog itself
dialog {
  padding: 1rem 3rem;
  background: var(--page-accent);
  max-width: 64ch;
}

// Style dialog button
.x {
  filter: grayscale(1);
  border: none;
  background: none;
  position: absolute;
  top: 0;
  right: 0.4rem;
}

// Additional page styling

body {
  font-family: system-ui, serif;
  line-height: 1.5;
  padding-bottom: 2rem;
}

main {
  max-width: 500px;
  margin: 0 auto;
  display: grid;
}

button {
  padding: 0.5rem;
  font-size: 1rem;
  background: var(--page-accent);
  border: 2px solid;
  border-radius: 0.5rem;
  justify-self: end;
}


              
            
!

JS

              
                
              
            
!
999px

Console