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="card">
  <header>
    <h2>Epic title</h2>
    <p>Lorem ipsum dolor sit amet</p>
  </header>
  <figure class="responsive-image">
    <img height="640" width="640" src="https://assets.codepen.io/2585/uszetlo5l6591.webp" alt="cyberpunk raining day in tokyo with purple and cyan lights">
    <figcaption>
      <a href="#">Source</a>
    </figcaption>
  </figure>
  <article>
    <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Odio asperiores voluptates officiis totam, est sequi iure libero rem nobis veniam consectetur commodi voluptatibus maxime labore cumque, dolore, quam eveniet magnam.</p>
  </article>
  <footer>
    <button>Like</button>
    <button>Share</button>
  </footer>
</div>
              
            
!

CSS

              
                @layer demo, images, cards;

@layer cards {
  @scope (.card) to (> header > *, > figure > *, > footer > *) {
    :scope {
      display: grid;
      background: oklch(50% none none / 20%);
      border-radius: 10px;
      border: 1px solid oklch(50% none none / 20%);
      
      @media (prefers-color-scheme: light) {
        background: white;
        box-shadow: 0 30px 10px -20px oklch(0% none none / 25%);
      }

      > header {
        display: grid;
        gap: .5ch;
        padding: 2ch;
      }

      > article {
        max-inline-size: 50ch;
        line-height: 1.5;
        padding: 2ch 2ch 1ch;
      }

      > footer {
        display: flex;
        justify-content: flex-end;
        padding: 1ch 2ch;
        gap: 1ch;
      }
    }
  }
}

@layer images {
  .responsive-image {
    max-inline-size: 50ch;
    aspect-ratio: 16/9;
    
    > img {
      max-inline-size: 100%;
      block-size: 100%;
      object-fit: cover;
      object-position: bottom;
    }
    
    > figcaption {
      text-align: center;
      padding-block: 1ch;
    }
  }
}

@layer demo.support {
  * {
    box-sizing: border-box;
    margin: 0;
  }

  html {
    block-size: 100%;
    color-scheme: dark light;
    
    @media (prefers-color-scheme: light) {
      background: #ccc;
    }
  }

  body {
    min-block-size: 100%;
    font-family: system-ui, sans-serif;

    display: grid;
    place-content: center;
    place-items: center;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console