Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <body>
  <header>
    <ul class="theme-list">
      <li><button data-name="base">Base Theme</button></li>
      <li><button data-name="radical">RaDiCaL Thǝmǝ</button></li>
      <li><button data-name="large">Large Font Theme</button></li>
    </ul>
  </header>
  <div class="content">
    <aside>
      <ul class="menu">
        <li>Home</li>
        <li>Blog</li>
        <li>Contact</li>
      </ul>
    </aside>
    <section id='main'>
      <h3>Hello, this is my cool site!</h3>
      <p>Look at all the neat things I write about!</p>
      <p>Click my ads so I can sustain myself off a passive income!</p>
    </section>
  </div>
</body>
              
            
!

CSS

              
                body {
  background-color: var(--bg-color);
  color: var(--font-color);
  font-size: var(--font-size);
}

.content {
  display: flex;
}

.theme-list {
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  padding-left:0;
  list-style: none;
}

#main {
  background-color:var( --content-bg-color);
  border: 1px solid #333;
  margin-left: 20px;
  padding: 14px;
  width: 550px;
}

.menu {
  font-family: var(--menu-font);
  padding-left: 10px;
}

.menu li {
  list-style: none;
  margin-bottom: 10px;
  margin-left: 0;
 
}

:root {
  --bg-color: #33ffcc;
  --font-color: black;
  --font-size: 14px;
  --content-bg-color: #fefefe;
  --menu-font: Helvetica, 'Courier New', san-serif;
}

.radical-theme {
    --bg-color: #ff31fa;
    --font-color: white;
    --content-bg-color: #00eeff;
    --menu-font: 'Lucida Grande', Sitka, san-serif;
}

.large-theme {
  --bg-color: #2EBD99;
  --font-size: 20px;
}

              
            
!

JS

              
                //Get the list of theme buttons
let list = document.querySelectorAll('.theme-list button');

//set up our click handler for later
let onClick = (e)=> {
  //pull out the name from the button's data attributes
  let selectedTheme = e.target.dataset.name;
  let body = document.querySelector('body');
  
  //select the body tag and overwrite its applied classes 
  if(selectedTheme === 'base') {
    //in the case of the base theme, we actually don't want any classes applied at all
    body.classList = '';
  } 
  else {
    body.classList = `${selectedTheme}-theme`;
  }
};

//loop through our list of buttons and apply an event handler to each
for(let button of list) {
  button.addEventListener('click', onClick);
}



              
            
!
999px

Console