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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

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


                <p>Safari (10.x, 11.x) <em>sometimes</em> fires multiple blur/focus events on clicking/tapping between form elements.</p>
<p>This bug is discussed in a <a href="">React issue</a> and filed in <a href="">Webkit</a> 😨</p>
<p><input type="text" value="Element 1" id="one">
  <input type="text" value="Element 2" id="two">
  <input type="text" value="Element 3" id="three">
    <button type="button" id="clear">
<p><label>Output</label> <textarea id="output" rows="20" cols="80" readonly></textarea></p>
<p>One possible solution is to throttle focus/blur events. Toggle below to show before/after</p>
<p><label for="use_ignore"><input type="checkbox" id="use_ignore"> Throttle events</label></p>
<p>Curiously, this bug doesn't seem to manifest on clicking the first element.</p>
<p>Disabling "Look up & data detectors" makes the issue to go away which explains why it triggers in MacOS only.</p>


                textarea {
  border: 0;
  background: #efefef;
label {
  display: block;


                const elementOne = document.getElementById("one");
const elementTwo = document.getElementById("two");
const elementThree = document.getElementById("three");
const out = document.getElementById("output");
const clearer = document.getElementById("clear");
const throttleIgnore = document.getElementById("use_ignore");

// functions

clearOutput = () => {
  out.value = "";

let logValue = [];
// 50ms throttle rate which is too fast for human interaction
// Fastest gamers can button mash around 100ms for reference
const throttleDuration = 50;

watchEvent = (element, eventName) => {
  // set the last event time to a safe default for this element
  if (!element.lastEvent) {
    element.lastEvent = 1;

  element.addEventListener(eventName, e => {

    const timeStamp = e.timeStamp;

    // This focus/blur event is too close to the last one for this element
    if (
        throttleIgnore.checked &&
        (eventName === "focus" || eventName === "blur") &&
        timeStamp < (element.lastEvent + throttleDuration)) {
      //ignore it

    logValue.push( + " => " + eventName);
    element.lastEvent = timeStamp;

    if (eventName === "click" || eventName === "focus") {
      out.value = out.value + logValue.join(" | ") + "\n";
      logValue = [];

// Add event listeners

clearer.addEventListener("click", clearOutput);


watchEvent(elementOne, "click");
watchEvent(elementOne, "focus");
watchEvent(elementOne, "blur");
watchEvent(elementTwo, "click");
watchEvent(elementTwo, "focus");
watchEvent(elementTwo, "blur");
watchEvent(elementThree, "click");
watchEvent(elementThree, "focus");
watchEvent(elementThree, "blur");