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

              
                <p>
  Theme:
  <label>
    <input type="radio" name="colorScheme" value="auto" checked>
    Auto
  </label>
  <label>
    <input type="radio" name="colorScheme" value="light">
    Light
  </label>
  <label>
    <input type="radio" name="colorScheme" value="dark">
    Dark
  </label>
</p>
<h1>Hello World!</h1>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Sed maiores quisquam eius corporis repellat qui. Quasi blanditiis recusandae ut distinctio beatae id nam quis, fugit eaque aliquam, aliquid autem dolore.</p>
<p>Perspiciatis similique facilis veniam vero ad, optio, voluptatem laudantium, tenetur magni voluptatum saepe ab error cum quibusdam voluptas nesciunt maiores debitis quas? Id aut unde a incidunt ea deserunt perferendis!</p>
<p>Error illum nostrum repellendus fuga perspiciatis, veritatis asperiores voluptatum voluptatibus beatae? Quidem nam voluptate dolores esse accusantium eligendi nesciunt ab commodi cumque. Fugit consequuntur repudiandae atque quisquam tenetur unde quae?</p>
<p>Ea deserunt modi vel dolores illo cum debitis corporis laborum neque harum, inventore, voluptas placeat perspiciatis? Commodi delectus ducimus consequatur voluptatum unde, consectetur ea? Quaerat mollitia laborum officiis illum blanditiis.</p>
<p>Alias architecto, ea impedit et quidem hic libero provident, assumenda dignissimos iste maxime tempora quae repudiandae non veritatis voluptatem ab harum? Fuga tempora provident reprehenderit praesentium animi adipisci, nihil molestiae.</p>

              
            
!

CSS

              
                :root {
  /* light theme in default (aka fallback) */
  --theme--background-color: #f0f0f0;
  --theme--color: #333;
  
  /* dark theme by device */
  @media (prefers-color-scheme: dark) {
    --theme--background-color: #333;
    --theme--color: #f9f9f9;
  }
  
  /* force light theme */
  &[data-color-scheme="light"] {
  --theme--background-color: #f0f0f0;
  --theme--color: #333;
  }
  
  /* force dark theme */
  &[data-color-scheme="dark"] {
    --theme--background-color: #333;
    --theme--color: #f9f9f9;
  }
}

body {
  background-color: var(--theme--background-color);
  color: var(--theme--color);
}

              
            
!

JS

              
                function main() {
  const colorSchemeRadios = [
    ...document.querySelectorAll('input[name="colorScheme"]')
  ];
  colorSchemeRadios.forEach((el) => {
    el.addEventListener("change", () => {
      const colorScheme = el.value;
      document.documentElement.setAttribute("data-color-scheme", colorScheme);
    });
  });
}

main();

              
            
!
999px

Console