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 is required to process package imports. If you need a different preprocessor remove all packages first.

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



Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO


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.


Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:


Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO


                body(ng-app="myApp" ng-controller="AppCtrl as app")
  b Description:
    | A very basic POC of decorating `$watchCollection()` to enable support
    | for observables. Instead of having to check for changes on every `$digest`,
    | it subscribes to the observable.
      | (Observable expressions are denoted by a trailing `$`.)
    | Use observable: 
    input(type="checkbox" ng-model="useObservable")
  |  | 
  button(ng-click="app.addItem()") Add item
  button(ng-click="app.editItem()") Edit Random item
        | Regular `ngRepeat` expression
        | (watchers: {{ ($$watchers.length || 0) - 1 }})
        //- One watcher is from the `{{ ... }}`, thus -1.        
      div(ng-repeat="item in app.items") {{ }}
        | Observable `ngRepeat` expression
        | (watchers: {{ ($$watchers.length || 0) - 1 }})
        //- One watcher is from the `{{ ... }}`, thus -1.        
      div(ng-repeat="item in app.items$") {{ }}
  // -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=-
  // Page Footer
    div(app="footerApp" ng-controller="FooterCtrl as footer" ng-cloak)
        b Angular v{{footer.version.full}}
        |  ({{footer.version.codeName}})
        != '&copy; '
        a(ng-href="{{}}" target="_blank")
          | {{}}




/* -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=- */
/* Page Footer */
body { padding-bottom: 2em; }
.footer { background-color: White; border-top: 1px solid rgba(100, 100, 100, 0.33); bottom: 0; display: block; font-size: 0.75em; height: 1.5em; left: 0; margin: 0 5px; overflow: auto; padding: 5px; position: fixed; right: 0; }
.footer > div { display: flex; flex-direction: row; }
.footer .left { flex-grow: 2; text-align: left; }
.footer .right { flex-grow: 1; text-align: right; }
[ng-cloak] { display: none !important; }



(function () {'use strict';

  module('myApp', []).
  controller('AppCtrl', AppCtrl).
  decorator('$rootScope', decorateRootScope).
  directive('test', testDirective);

// Functions - Definitions
function AppCtrl($rootScope) {
  // Variables - Private
  var self = this;
  var items = [{ name: 'John' }, { name: 'Gkalpak' }, { name: 'Igor' }];
  var items$ = new Rx.BehaviorSubject(items);
  // Variables - Public
  self.items = items;
  self.items$ = items$;
  // Functions - Public
  self.addItem = addItem;
  self.editItem = editItem;
  self.getWatcherCount = getWatcherCount;
  // Function - Definitions
  function addItem() {
    items.push({ name: 'Test' });
  function editItem() {
    var item = items[Math.floor(Math.random()*items.length)]; += '2';
  function getWatcherCount() {
    var watcherCount = 0;
    var pendingChildHeads = [$rootScope];

    while (pendingChildHeads.length) {
      var currentScope = pendingChildHeads.shift();
      while (currentScope) {
        watcherCount += (currentScope.$$watchers || []).length;
        currentScope = currentScope.$$nextSibling;

    return watcherCount;

function decorateRootScope($delegate) {
  var scopeProto = Object.getPrototypeOf($delegate);
  var oldWatchCollection = scopeProto.$watchCollection;
  scopeProto.$watchCollection = newWatchCollection;
  return $delegate;
  // Helpers
  function newWatchCollection(expr, listener) {
    var scope = this;
    if (!/\$$/.test(expr)) {
      return oldWatchCollection.apply(scope, arguments);
    var observable = scope.$eval(expr);
    var subscription = observable.subscribe(function(newValue) {
      scope.$evalAsync(function() {
    return subscription.unsubscribe.bind(subscription);


/* -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=- */
/* Page Footer */
(function () {'use strict';
var app = 'footerApp';
angular.module(app, []).controller('FooterCtrl', FooterCtrl);
angular.bootstrap(document.querySelector('[app="' + app + '"]'), [app]);
function FooterCtrl($window) {
  this.version = $window.angular.version; = {name: 'GKalpak', url: '//'};

Why did the programmer quit her job? She didn't get arrays.