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

              
                <main>

  <figure>
    <figcaption>myday.class.php</figcaption>
    <pre><code contenteditable="false" tabindex="0" spellcheck="false">/**
 * myDay.class.php
 *
 * @author daemon.devin
 * @version 1.0 beta 1
 * @uses drugs
 * @todo hustle
 * @return laughter
 */

class myDay {

    public function &live(self $objective, $mindState) {
        return $objective->$mindState;
    }
    
    protected function invoke($objective, $mindState, $how) {
        return call_user_func_array(array($objective, $mindState), $how);
    }
}

class Morning extends myDay {
    private $name;
    protected $tasks;

    public function __construct($mindState) {
        $this->name = $mindState;
        $this->tasks = array();
    }
    
    public function initialize(Evening $high, $get) {
        $this->tasks[$get] = $high;

        // instead, we get a reference from the dispatcher:
        $current = &$this->live($high, "sober");

        // ... and change that:
        $current = $this;
    }
    public function loaded($get) {
        $this->invoke($this->tasks[$get], "loaded", array());
    }
}

class Evening extends myDay {
    private $drug;
    private $function;
    private $mindState;
    protected $owner;

    public function __construct($dope, $relax, $high) {
        $this->drug = $dope;
        $this->function = $relax;
        $this->mindState = $high;
    }

    protected function loaded() {
        echo ("Smoking ".$this->drug." to get ".$this->mindState." and ".$this->function."\n");
    }
}

$now = new Morning("sober");
$soon = new Evening('weed', 'unwind', 'loaded');
$now->initialize($soon, "smoke");
$now->loaded("smoke");</code></pre>
  </figure>

</main>
              
            
!

CSS

              
                body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #444;
  font: normal normal normal 100%/1.4 georgia, serif;
}

main {
  display: block;
  width: 95%;
  min-width: 18em;
  margin: 2em auto;
}

figure {
  display: block;
  margin: 1em 0;
  width: 100%;
  color: #9e9e9e;
  border: 1px solid #111;
  border-radius: 3px;
  background: rgb(22, 22, 22);
}

figure figcaption {
  display: block;
  font-family: sans-serif;
  padding: 5px 10px 4px 10px;
  border-bottom: 1px solid #111;
  border-radius: 3px 3px 0 0;
  font-weight: bold;
  font-variant: small-caps;
  background: #111;
  color: #9e9e9e;
}

.numbers {
   cursor: context-menu;
   -webkit-user-select: none;
	-moz-user-select: none;
  -ms-user-select: none;
	user-select: none;
  box-shadow: inset 0 0 4px 0 rgba(0, 0, 0, 0.5);
}

pre,
pre * {
  font: normal normal normal 1em/1.4 monaco, courier, monospace;
}

pre {
  font-size: 0.8em;
}

pre,
pre code,
pre samp {
  display: block;
  margin: 0;
  cursor: text;
}

pre code,
pre samp {
  /* enforce white-space for IE7 */
  white-space: pre;
  /* enforce word-wrap for mobile safari */
  word-wrap: normal;
  padding: 10px;
  -moz-tab-size: 4;
  -o-tab-size: 4;
  tab-size: 4;
  overflow-x: auto;
  box-shadow: inset 0 1px 0 1px rgba(0, 0, 0, 0.5);
}


/* additional focus rules to provide a visual cue */

pre [contenteditable]:focus {
  border-radius: 0 0 3px 0;
  background: #fff;
  outline: none;
  background: rgb(22, 22, 22);
  box-shadow: inset 0 1px 4px 1px rgba(0, 0, 0, 0.5);
}

pre.line-numbers {
  position: relative;
}

pre.line-numbers code,
pre.line-numbers samp {
  margin-left: 3em;
  border-left: 1px solid #000;
}

pre.line-numbers > div {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 0 0 0 3px;
  overflow: hidden;
  counter-reset: line;
}

pre.line-numbers > div > span {
  display: block;
  width: 2.5em;
  padding: 0 0.5em 0 0;
  text-align: right;
  color: #777;
  overflow: hidden;
  counter-increment: line;
}

pre.line-numbers > div > span::before {
  content: counter(line);
}

pre.line-numbers > div > span:first-child {
  margin-top: 10px;
}

pre.line-numbers > div > span:nth-child(odd) {
  background: #111;
}

@media print {
  pre code {
    overflow-x: visible;
    white-space: pre-wrap;
  }
  pre.line-numbers div {
    display: none;
  }
  pre.line-numbers > code,
  pre.line-numbers > samp {
    margin-left: 0;
  }
}

code.hljs {
    padding-top: 10px;
}
/* double-up the syntax elements for cross-browser RTF-keystroke support */

pre b,
pre strong {
  font-weight: normal;
  color: #039;
}

pre u,
pre u b,
pre u strong {
  text-decoration: none;
  color: #083;
}

pre i,
pre em,
pre i *,
pre em *,
pre i * *,
pre em * * {
  letter-spacing: -0.1em;
  text-decoration: none;
  font-style: normal;
  color: #c55;
}

.hljs {
  color: #a9b7c6;
  background: rgb(22, 22, 22);
  display: block;
  overflow-x: auto;
  padding: 0.5em;
}

.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
  color: #FF8040;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-deletion {
  color: #569CD6;
}

.hljs-variable,
.hljs-template-variable,
.hljs-link {
  color: #FF8040;
}

.hljs-comment,
.hljs-quote {
  color: #57A64A;
}

.hljs-meta {
  color: #D2A8A1;
}

.hljs-string,
.hljs-attribute,
.hljs-addition {
  color: #FF0000;
}

.hljs-section,
.hljs-title,
.hljs-type {
  color: #ffc66d;
}

.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
  color: #e8bf6a;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: bold;
}
              
            
!

JS

              
                	(function() {
	  for (var tags = ['div', 'figure', 'figcaption'], i = 0; i < tags.length; i++) {
	    document.createElement(tags[i]);
	  }
	})();

	(function() {
	  //filter IE8 and earlier which don't support the generated content
	  if (typeof(window.getComputedStyle) == 'undefined') {
	    return;
	  }

	  //get the collection of PRE elements
	  var pre = document.getElementsByTagName('pre');
    //now iterate through the collection
	  for (var len = pre.length, i = 0; i < len; i++) {
	    //get the CODE or SAMP element inside it, 
	    //or just in case there isn't one, continue to the next PRE
	    var code = pre[i].getElementsByTagName('code').item(0);
	    if (!code) {
	      code = pre[i].getElementsByTagName('samp').item(0);
	      if (!code) {
	        continue;
	      }
	    }

	    //create a containing DIV column (but don't append it yet)
	    //including aria-hidden so that ATs don't read the numbers
	    var column = document.createElement('div');
	    column.setAttribute('aria-hidden', 'true');
      column.setAttribute('class', 'numbers');

	    //split the code by line-breaks to count the number of lines
	    //then for each line, add an empty span inside the column
	    for (var n = 0; n < code.innerHTML.split(/[\n\r]/g).length; n++) {
	      column.appendChild(document.createElement('span'));
	    }

	    //now append the populated column before the code element
	    pre[i].insertBefore(column, code);

	    //finally add an identifying class to the PRE to trigger the extra CSS
	    pre[i].className = 'line-numbers';
	  }

	})();
              
            
!
999px

Console