Pen Settings



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


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.


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.


                <h1>Random Phrase Generator</h1>

<button data-button=green>Generate Phrase</button>



                [data-button] {
  display: block;
  margin: 1em auto;

li {
  margin: 1em 0;
  font-size: 14pt;


                // Who
const who = [
  `the captain`,
  `a nearby stranger`

// What
const what = [

// When
const when = [
  `right freaking now`,

// Where
const where = [
  `my place`,
  `the office`,
  `down by the bridge`,
  `wherever that is`

// Why
const why = [
  `I'm hungry`,
  `you never know what's gonna happen`,
  `you forgot it last time`,
  `I never signed up for this`

// Pick random element from array
const pick = arr => arr[Math.floor(Math.random() * arr.length)]

// Phrases
const phrase = [
  () => `I need ${pick(who)} to fetch my ${pick(what)} from ${pick(where)} ${pick(when)}.`,
  () => `This is the LAST time I will lend ${pick(who)} my ${pick(what)} because ${pick(why)}.`,
  () => `I want a ${pick(what)}, and I want it ${pick(when)}!`,
  () => `“You never know, ${pick(when)} you might find your ${pick(what)} has been waiting for you at ${pick(where)} this whole time,” says ${pick(who)}, “and that just means ${pick(why)}!”`

// Log random phrases
const populate = () => {
  let li = document.createElement('li')
  let ul = document.querySelector('ul')
  li.textContent = pick(phrase)()
  ul.insertBefore(li, ul.firstChild)

for (var i=10; i--;) {

  .addEventListener('click', populate)