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">
  <details name="my-accordion">
    <summary>
      This is an example
      <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
        <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" aria-hidden="true" />
      </svg>
    </summary>
    <div class="details-info">
      <p>Lorem ipsum dolor sit amet, consectetur</p>
      <img src="https://picsum.photos/900/600?random=1" alt="" />
      <p>Phasellus vel erat a ante pharetra pharetra.</p>
    </div>
  </details>
  <details name="my-accordion" open>
    <summary>
      Of an accordion
      <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
        <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" aria-hidden="true" />
      </svg>
    </summary>
    <div class="details-info">
      <h2>Sweet</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras convallis sodales erat vel accumsan. Nam eget massa nec sem vulputate ullamcorper vel quis justo. Duis rhoncus tempor tempus. Nulla facilisi. Maecenas nulla ante, lacinia ac consectetur non, aliquet sollicitudin libero. Quisque congue odio sodales dui fermentum ac laoreet mauris eleifend. Nulla facilisi. Phasellus vel erat a ante pharetra pharetra.</p>
    </div>
  </details>
  <details name="my-accordion">
    <summary>
      With just HTML
      <svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
        <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" aria-hidden="true" />
      </svg>
    </summary>
    <div class="details-info">
      <h2>Lorem ipsum dolor sit amet</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras convallis sodales erat vel accumsan. massa nec sem vulputate ullamcorper vel quis justo. Duis rhoncus tempor tempus. Nulla facilisi. Maecenas nulla ante, lacinia ac consectetur non, aliquet sollicitudin libero. Quisque congue odio sodales dui fermentum ac laoreet mauris eleifend. Nulla facilisi. Phasellus vel erat a ante pharetra pharetra.</p>
    </div>
  </details>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap");

@layer defaults, demo;

@layer demo {
  :root {
    --container-width: 800px;
    --body-color: #1a1a1a;
    --collapse-bg: #e5fcff;
    --collapse-color: #1a1a1a;
    --collapse-line-color: #acacde;
    --collapse-icon-color: #b8336a;
    --collapse-box-shadow: rgba(0, 0, 0, 0.16) 0px 10px 36px 0px,
      rgba(0, 0, 0, 0.06) 0px 0px 0px 1px;
  }

  details {
    background: var(--collapse-bg);
    color: var(--collapse-color);
    box-shadow: var(--collapse-box-shadow);
    font-family: "Lato", sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    &:first-child {
      border-radius: 0.5rem 0.5rem 0 0;
    }
    &:last-child {
      border-radius: 0 0 0.5rem 0.5rem;
    }
  }

  summary {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    cursor: pointer;
    list-style-type: none;
    font-weight: 400;
    font-size: 1.3rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2),
      0px -2px 4px rgba(255, 255, 255, 0.2);
  }

  summary,
  .details-info {
    padding: 1rem;
  }

  summary::-webkit-details-marker {
    display: none;
  }

  .details-info {
    border-top: 1px solid var(--collapse-line-color);
  }

  summary .icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    transition: transform 0.26s;
    color: var(--collapse-icon-color);
  }

  details[open] summary .icon {
    transform: rotate(180deg);
  }
}

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

  body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: "Lato", sans-serif;
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--body-color);
    background-image: linear-gradient(to bottom left, #bd00ff 0%, #ffec00 100%);
  }

  @supports (background: linear-gradient(in oklab, red, tan)) {
    body {
      background-image: linear-gradient(
        to bottom left in oklab,
        oklch(55% 0.45 309) 0%,
        oklch(100% 0.4 95) 100%
      );
    }
  }
  img {
    display: block;
    max-width: 100%;
    margin: 0 0 24px 0;
  }

  h2 {
    margin: 0 0 8px 0;
    font-family: "Lato", serif;
    font-size: 1.5rem;
    font-weight: 700;
  }

  .container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 20px;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console