Pen Settings

HTML

CSS

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

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

Auto Save

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

              
                <button no-js on-click-set-attribute=".style-target style color:blue;font-weight:bold;">
 Set styles
</button>

<button no-js on-click-remove-attribute=".style-target style">
  Remove styles
</button>
<br>
<p class="style-target">
  Watch my style change!
</p>

<hr align=left width=200 />
<br/>

<button no-js on-click-add-class=".class-target arial-font">
  Add class
</button>

<button no-js on-click-remove-class=".class-target arial-font">
  Remove class
</button>

<button no-js on-click-toggle-class=".class-target arial-font">
  Toggle class
</button>
<br />
<p class="class-target">
  Watch my font change!
</p>

<hr align=left width=200 />
<br/>

<button no-js on-click-set-text=".text-target Behold my new text value!">Set text</button>
<br />
<p><div class="text-target">Watch my text change!</div></p>

<hr align=left width=200 />
<br/>

<label for="change-bgcolor-text">
  Focus on the textbox below to see its background color change, <br />
  then tab off of it to see the background color change back.
</label>
<p>
<input id="change-bgcolor-text" type="text"
  no-js on-focus-remove-class-self="no-focus" 
        on-focus-add-class-self="focus" 
        on-blur-remove-class-self="focus" 
        on-blur-add-class-self="no-focus" />
</p>

<br />
<hr />
<p style="text-align:left;">If you find this demo useful, please consider <a href="https://www.paypal.me/RobertGravelle/1" target="_blank">donating $1 dollar</a> (secure PayPal link) for a coffee or purchasing one of my songs from <a href="https://ax.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?term=rob%20gravelle" target="_blank">iTunes.com</a> or <a href="http://www.amazon.com/s/ref=ntt_srch_drd_B001ES9TTK?ie=UTF8&field-keywords=Rob%20Gravelle&index=digital-music&search-type=ss" target="_blank">Amazon.com</a> for only 0.99 cents each.</p>
<p style="text-align:left;">Rob uses and recommends <a href="http://www.mochahost.com/2425.html" target="_blank">MochaHost</a>, which provides Web Hosting for as low as $1.95 per month, as well as unlimited emails and disk space!</p>


              
            
!

CSS

              
                .arial-font {
  font-family: Arial, Helvetica, sans-serif;
}

.focus {
  background-color: powderblue;
}

.no-focus {
  background-color: white;
}

input[type="text"] {
  width: 200px;
  border: solid black 1px;
}
              
            
!

JS

              
                /*
* Signature:
*   on-[evtType]-[action]-[propertyType] = "target propertyName propertyValue"
*   on-[evtType]-[action]-[propertyType] = "target propertyValue"
*   on-[evtType]-[action]-[propertyType]-self = "propertyName propertyValue"
*
* Supported propertyTypes:
*   attribute:
*     on-[eventType]-add||set-attribute="[target] [attributeName] [attributeValue]"
*     on-[eventType]-remove-attribute="[target] [attributeName]"
*   class:
*     on-[eventType]-add-class="[target] [className]"
*     on-[eventType]-set-class="[target] [className]"
*     on-[eventType]-remove-class="[target] [className]"
*     on-[eventType]-toggle-class="[target] [className]"
*     on-[eventType]-switch-class="[target] [className]"
*   id:
*     on-[eventType]-add||set-id="[target] [idValue]"
*     on-[eventType]-remove-id="[target]"
*   dom:
*     on-[eventType]-remove-dom="[target]"
*   value:
*     on-[eventType]-set-value="[form input target] [value]"
*     on-[eventType]-reset-value="[form input target]"
*   text:
*     on-[eventType]-set-text="[target] [textValue]"
*
*/
(function() {
  function NoJS (dom) {
    this.js(dom)
  }

  NoJS.prototype.js = function (dom) {
    dom = dom || 'html';
    var this_ = this;
    var isSelf = false;
    document.querySelector(dom).querySelectorAll('[no-js]').forEach(function(el) {
      Object.keys(el.attributes).forEach(function(prop) {
        var attr = el.attributes[prop];

        // to enable support for single and double dashes.
        // note the order of condition checking is important.
        if (attr.name.indexOf('on--') === 0) {
          var doubleDash = true;
          console.warn('Deprecation warning: using double dashes "--" are deprecated. Use a single dash "-" instead.')
        } else if (attr.name.indexOf('on-') === 0) {
          var doubleDash = false;
        } else {
          return;
        }

        var signatureParts = attr.name.split(doubleDash ? '--' : '-');
        var paramValues = attr.value.split(' ');

        var eventType = signatureParts[1], action = signatureParts[2], propertyType = signatureParts[3];

        if (signatureParts.length === 5 && signatureParts[4] === 'self') {
          var target = el;
          isSelf = true;
        } else {
          var target = paramValues[0];
        }

        var propertyValue;
        if (action !== 'remove' || action !== 'reset') {
          var index = this_._getPropertyValueIndex(propertyType, isSelf)
          // join space containing values that might have been split.
          propertyValue = paramValues.splice(index).join(' ')
        }

        var options = {
          action: action,
          target: target,
          sourceElement: el,
          propertyType: propertyType,
          propertyValue: propertyValue,
          propertyName: propertyType === 'attribute' ? paramValues[1] : propertyType
        }

        el.addEventListener(eventType, function(e) {
          this_._handler(options);
        })
      })
    })
  }

  NoJS.prototype._handler = function (options) {
    var targets = typeof options.target === "string" ? document.querySelectorAll(options.target) : [options.target];
    targets.forEach(function(el) {
      if (options.propertyType === 'class') {
        if (options.action === 'set') {
          el.className = options.propertyValue
        } else if (options.action == 'switch') {
          el.classList.remove(options.propertyValue)
          options.sourceElement.classList.add(options.propertyValue)
        } else {
          el.classList[options.action](options.propertyValue)
        }
      }

      else if (options.propertyType === 'attribute' || options.propertyType === 'id') {
        if (options.action === 'remove') {
          el.removeAttribute(options.propertyName)
        } else if (options.action === 'add' || options.action == 'set') {
          el.setAttribute(options.propertyName, options.propertyValue);
        }
      }

      else if (options.propertyType === 'dom' && options.action === 'remove') {
        el.remove();
      }

      else if (options.propertyType === 'value') {
        if (options.action === 'set') {
          el.value = options.propertyValue;
        } else if (options.action === 'reset') {
          el.value = null;
        }
      }

      else if (options.propertyType === 'text' && options.action === 'set') {
        el.innerText = options.propertyValue;
      }
    })
  }

  NoJS.prototype._getPropertyValueIndex = function (propertyType, isSelf) {
    var index = propertyType === 'attribute' ? 2 : 1;
    return isSelf ? index - 1 : index;
  }

  document.addEventListener('DOMContentLoaded', function() {
    window.no = new NoJS();
  })
})()
              
            
!
999px

Console