Pen Settings



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


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


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.


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 lang="eng">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
  <title>DOM Manipulation: toggle</title>

    <h1>Add me some style</h1>
    <h2 class="active">Remove my style</h2>
    <h3>Add me a new style</s>
    <button class="btn1">Click me!</button>
    <button class="btn2">Click me!</button>
    <button class="btn3">Click me!</button>



.active {
  font-family: 'Lucida Sans Unicode','Lucida Grande','Lucida Sans','DejaVu Sans Condensed',sans-serif;
  background-color: coral;
  border-radius: 4px;
  padding: 5px 0;
  color: #C1EFFF;

.active2 {
  text-shadow: 4px 4px 2px rgba(0,0,0,0.6);
   font-style: italic;

section {
  width: 90%;
  display: flex;
  justify-content: space-around;
  align-items: center;

button {
  margin: 3rem 0 0 5rem;
  padding: 4px 10px;



// Adds the class "active" to the H1
let firstButton = document.querySelector(".btn1");

firstButton.addEventListener("click", function addClass(){
  let headlineOne = document.querySelector("h1");
  return headlineOne.classList.toggle("active");            

// Removes the class "active" from the H2, as it already has it applied
let secondButton = document.querySelector(".btn2");

secondButton.addEventListener("click", function removeClass(){
  let headlineTwo = document.querySelector("h2");
  return headlineTwo.classList.toggle("active");            

// Adds the class "active2" to the H3
let thirdButton = document.querySelector(".btn3");

thirdButton.addEventListener("click", function addNewClass(){
  let headlineThree = document.querySelector("h3");
  return headlineThree.classList.toggle("active2");