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

              
                <!--
Fiddling with the <dialog> element...

Problems:
* Firefox/Chromium: Element should be required to have a 
  browser-provided Close button (per this example,
  none is provided by content).
* Firefox:
  * <dialog> element is hidden behind about:config flag
  * Doesn't acknowledge the ::backdrop pseudo-element
    so it won't recognize clicks that aren't directly on the
    <dialog> box.
  * Doesn't accept [Esc] from the keyboard to close the <dialog>.
-->

<button
 onclick="window.dialog.showModal()"
>Open</button>
<dialog id="dialog">
Modal: click backdrop to close.<br>
Any click sends data to Console.
</dialog>
              
            
!

CSS

              
                dialog {
  cursor: default;
  pointer-events: none;
}
/*
Firefox ~81 doesn't support the pseudo at all.
No styling, and no pointer-event recognition to
call the click handler.
*/
dialog::backdrop {
  background-color: rgba(100,100,100,0.8);
  /* 
  Chrome ~78 doesn't differentiate the pseudo's cursor from
  the element's, so this overrides.
  */
  cursor: pointer;
  pointer-events: all;
}
              
            
!

JS

              
                document
	.getElementById('dialog')
  .addEventListener(
  	'click',
    ((event) => {
      let rect = event.target.getBoundingClientRect();
      
      console.log(
`
ClientX: ${event.clientX}
rect.left: ${rect.left}
rect.right: ${rect.right}

ClientY: ${event.clientY}
rect.top: ${rect.left}
rect.bottom: ${rect.bottom}
`
      );
    	if (rect.left > event.clientX ||
          rect.right < event.clientX ||
          rect.top > event.clientY ||
          rect.bottom < event.clientY
      ) {
          window.dialog.close();
      }
    })
  );
              
            
!
999px

Console