Pen Settings



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


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


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.


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.


                <div class="actions">
  <button type="button" id="openDialogButton">Click Me</button>

<dialog id="myDialog">
  <section class="body">
    <p> Coffee, the world's favorite beverage, awakens the senses and fuels our lives. Made from roasted Coffea plant seeds, it offers complex flavors and aromas. Enjoyed as a morning ritual or a midday pick-me-up, coffee's energizing caffeine enhances focus and alertness, making it a cherished companion that brings people together and sparks creativity.</p>
    <p>Coffee is more than a drink; it's a cultural symbol and cherished ritual worldwide. From Italian espresso to Turkish coffee and artisanal pour-overs, each culture has its unique approach. Whether enjoyed black or infused with milk, spices, or syrups, coffee's versatility is undeniable. It sustains millions of livelihoods, from farmers to baristas, and as we savor its rich flavors, coffee ignites joy, connection, and fuels our daily endeavors.</p>
  <footer class="actions">
    <button type="button" id="closeDialogButton" autofocus>Close</button>


                :root, ::backdrop {
  --primary: #577590;
  --primary-contrast: white;
  --accent: #F08A4B;
  --backdrop: rgba(242, 165, 65, .56);
  --text: #1a252f;

* { box-sizing: border-box }

html {
  margin: 0;
  padding: 0; 

body { 
  font-family: sans-serif;
  color: var(--text);

:where(h1, h2, h3, h4, h5, h6) { color: var(--primary) }

button {
  background: var(--primary);
  color: var(--primary-contrast);
  border: none;
  padding: .5rem 2rem;
  border-radius: 4px;
button:where(:focus, :focus-visible) {
  outline-offset: 2px;
  outline-color: var(--accent);

dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(5px);

dialog[open] {
  display: grid;
  grid-template-rows: min-content auto min-content;
  width: 75svw;
  height: 75svh;
  padding: 0;
  border: none;
  border-radius: 4px;
  box-shadow: 0 0 10px var(--primary);
dialog > header {
  padding: .5rem 1rem;
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 2px 0 2px var(--primary)
dialog > header > h2 { 
  color: inherit;
  margin: 0;
dialog section.body { 
  overflow-y: auto;
  padding-left: 1rem;
  padding-right: 1rem;
dialog > footer {
  padding: .5rem 1rem;
  box-shadow: -2px 0 2px var(--primary);



                (() => {
  'use strict'
  //  The dialog  
  const myDialog = document.getElementById('myDialog')

  //  Open and close buttons
  const openDialogButton = document.getElementById('openDialogButton')
  const closeDialogButton = document.getElementById('closeDialogButton')
  //  On click event listener that opens the dialog
  openDialogButton.addEventListener('click', () => {
    //  open the dialog
    //  put the focus on the close button
  //  On click event listener that closes the dialog
  closeDialogButton.addEventListener('click', () => {
    //  close the dialog