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

              
                <main>
  <h1>Learn web development</h1>
  <div class="course">
    <h2>Learn CSS</h2>

    <details open>
      <summary>Welcome to Learn CSS!</summary>
      <p>An evergreen CSS course and reference to level up your web styling expertise.</p>
      <p><a href="#">Read Article</a></p>
    </details>

    <details>
      <summary>Box Model</summary>
      <p>Everything displayed by CSS is a box. Understanding how the CSS Box Model works is therefore a core foundation of CSS.</p>
      <p><a href="#">Read Article</a></p>
    </details>

    <details>
      <summary>Selectors</summary>
      <p>To apply CSS to an element you need to select it. CSS provides you with a number of different ways to do this, and you can explore them in this module.</p>
      <p><a href="#">Read Article</a></p>
    </details>

    <details>
      <summary>…</summary>
      <p><em>(chapters 4 to 30 of this course have been omitted for demonstation purposes)</em></p>
    </details>
  </div>
</main>
              
            
!

CSS

              
                @layer reset {
  *,
  *:after,
  *:before {
    box-sizing: border-box;
  }

  * {
    margin: 0;
    padding: 0;
  }

  ul[class] {
    list-style: none;
  }

  label {
    cursor: pointer;
    max-width: max-content;
    user-select: none;
  }
}

@layer baselayout {
  html {
    margin: auto;
    line-height: 1.5;
    font-size: 1.25em;
    font-family: "Syne", sans-serif;
    min-height: 100%;
    background: white;
  }

  body {
    width: 100%;
    max-width: 120ch;
    margin: 0 auto;
    min-height: 100dvh;
    padding: 2em;
  }

  footer {
    text-align: center;
    font-style: italic;
    margin-top: 2rem;
  }

  h1,
  h2,
  summary {
    font-family: "Anybody", sans-serif;

    text-decoration: underline;
    text-decoration-color: hsl(156deg 100% 50% / 50%);
    text-decoration-thickness: 0.2rem;
    text-decoration-style: wavy;
    text-decoration-skip-ink: none;
  }

  h2 {
    margin: 2em 0 0.5em 0;
    text-wrap: balance;
  }

  a {
    color: inherit;
  }
}

@layer components {
  @layer course {
    .course {
      counter-reset: chapter;
    }

    .course details {
      counter-increment: chapter;
    }

    .course summary::before {
      content: counter(chapter);
      background: var(--border-color);
      color: white;
      display: inline-block;
      height: 1lh;
      aspect-ratio: 1;
      text-align: center;
      border-radius: 50%;
      margin-right: 0.5em;
    }

    .course details a {
      display: inline-block;
      background: var(--border-color);
      color: white;
      text-decoration: none;
      padding: 0.5em 0.7em;
      font-size: 0.8em;
      text-transform: uppercase;
      background-color: var(--border-color);

      &:hover {
        background-color: lch(from var(--border-color) calc(l * 0.9) c h);
      }
    }
  }
  @layer accordion {
    details {
      --border-color: #6300ff;
      border: 0.25em solid var(--border-color);
      overflow: hidden;
      margin: 0;

      > summary {
        background: #ccc;
        padding: 0.5em;
        border-bottom: 0.25em solid var(--border-color);
        cursor: pointer;

        transition: background 0.25s ease, color 0.25s ease;

        &:hover {
          background: #b4b4b4;
        }
      }

      &[open] {
        border-bottom: 0.25em solid var(--border-color);

        > summary {
          background: #b4b4b4;
        }
      }

      > *:not(summary) {
        padding: 1em;
      }
    }

    /* Visually group successive siblings together */
    details:has(+ details) {
      border-bottom: none;
    }
    details + details {
      border-top: none;
    }
    :not(details) + details,
    details:first-child {
      border-top-left-radius: 0.5em;
      border-top-right-radius: 0.5em;
    }
    details:not(details:has(+ details)) {
      border-bottom-left-radius: 0.5em;
      border-bottom-right-radius: 0.5em;

      &:not([open]) summary {
        border-bottom: 0;
      }
    }
  }
}

@layer utilities {
  .float-right {
    float: right;
    margin-left: 0.5em;
  }
  .float-left {
    float: left;
    margin-right: 0.5em;
  }
  *:has(> .float-right, > .float-left) {
    display: flow-root;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console