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 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.


                <h1>The difference between <code>event.stopPropagation()</code> and <code>event.stopImmediatePropagation()</code></h1>

<p>If you click on the <code>button</code> element, the <code>"I'm a div"</code> alert <strong>WILL NOT</strong> show. It will only show if you click <em>elsewhere</em> inside the purple area. Both methods behave the same in this respect.</p>


  <li>With the <code>stopPropagation()</code> method, the <code>"I'm a button!"</code> alert <strong>WILL</strong> show.</li>
  <li>With the <code>stopImmediatePropagation()</code> method, the <code>"I'm a button!"</code> alert <strong>WILL NOT</strong> show.</li>

<p>Try swapping them in the JavaScript editor to see what happens. For more information, check out my blog post:</p>

  <a href="">The difference between <code>event.stopPropagation()</code> and <code>event.stopImmediatePropagation()</code></a>

  <button type="button">Click Me!</button>


                :root {
  font-size: 16px;

body {
  width: 88%;
  max-width: 34em;
  margin: 1em auto;
  font: 1em/1.5 Arial, sans-serif;

code {
  color: #d14;

li + li {
  margin-top: 1em;

a {
  color: #0277bd;

a:hover {
  text-decoration: none;

a code {
  color: inherit;

div {
  padding: 1em;
  background-color: #639;

button {
  font: inherit;


                var div = document.querySelector("div");
var button = div.querySelector("button");

// This WILL NOT run when the button is clicked
div.addEventListener("click", function () {
  alert("I'm a div!");

button.addEventListener("click", function (event) {

  // Try changing which line is commented to see what happens! 👇

  // With this line, the "I'm a button!" alert WILL show

  // With this line, the "I'm a button!" alert WILL NOT show
  // event.stopImmediatePropagation();


// This WILL NOT run when the button is clicked
button.addEventListener("click", function () {
  alert("I'm a button!");

// Learn more: