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

              
                <!-- Ref https://web.dev/cq-stable/ -->

<p>Below are two instances of Foo component. When it’s in a narrow container, its border-colour changes. Resize the viewport so that the percentage-based width of “sidebar” gets narrow enough to trigger the change to Foo.</p>

<div class="wrapper">

  <main>
    <h2>Main column</h2>
    <div class="foo">
      <h3>Lorem ipsum</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Obcaecati facilis architecto animi odio reprehenderit repudiandae dignissimos beatae expedita ad pariatur quam accusantium accusamus, consequuntur perspiciatis similique nesciunt. Quis, error corrupti? Lorem ipsum, dolor sit amet consectetur adipisicing elit. Obcaecati facilis architecto animi odio reprehenderit repudiandae dignissimos beatae expedita ad pariatur quam accusantium accusamus, consequuntur perspiciatis similique nesciunt. Quis, error corrupti?
      </p>
    </div>
  </main>

  <div class="sidebar">
    <h2>Sidebar</h2>
    <div class="foo">
      <h2>Lorem ipsum</h2>
      <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Natus ea assumenda debitis quas dolorem, consectetur est tempore sapiente, cupiditate quis aliquid accusamus, doloribus minus deserunt. Eum, fugit nesciunt? Deserunt, sit.
      </p>
    </div>
  </div>

</div>
              
            
!

CSS

              
                main {
  container: ctr-main / inline-size;
}

.sidebar {
  container: ctr-sidebar / inline-size;
  max-width: 25%;
}

.foo {
  padding: 1em;
  border: 1px solid firebrick;
}

@container ctr-sidebar (max-width: 300px) {
  .foo {
    border: 1px solid blue;
  }
}

body {
  font-family: system-ui, sans-serif;
}
p {
  max-width: 60ch;
}
.wrapper {
  display: flex;
  gap: 1em;
}

.wrapper > * {
  flex: 1;
}

              
            
!

JS

              
                
              
            
!
999px

Console