Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


Save Automatically?

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.


                <h1>So this only super works under two circumstances</h1>

  <li>You have one of following browsers: Chrome 76, Firefox 67 or Safari 12.1</li>
  <li>And you're using your systems dark mode.</li>

  <input type="checkbox" name="Toggle" id="darkmode" />
  <label for="darkmode">Dark Mode</label>


                :root {
  --dark: #333;
  --light: #f7f7f7;
  --background: var(--light);
  --color: var(--dark);

.DarkMode {
  --background: var(--dark);
  --color: var(--light);

html {
  background: var(--background);
  color: var(--color);

/* Not super relevant to the demo */

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica,
    Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;

body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px;

ul {
  font-size: 125%;



                const checkbox = document.querySelector('input[type="checkbox"]');
const root = document.querySelector("html");

function checkSystem() {
  const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
  if (prefersDark) {
  } else {

function initDarkMode() {

  if (root.classList.contains("DarkMode")) {
    checkbox.setAttribute("checked", true);

  checkbox.addEventListener("change", (event) => {
    const isDarkMode = root.classList.contains("DarkMode");
    checkbox.setAttribute("checked", isDarkMode)