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


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.


                <div id="primary-content">
  <div class="stats">
    <button id="add">Click me to add some bacon!</button>
    <button id="reset">Reset</button>
    <span class="info">Current size: <span id="size"></span></span>
  <p class="intro">A delicious example of the <a href="">ResizeObserver</a> API. As of Feb 12th, 2020 this requires a Chrome or Firefox browser.</p>


                body {
  font-family: sans-serif;
p {
  display: block;
  font-size: 1.25em;

.intro {
  padding: 1em;
  background-color: #e6ffe2;

button {
  font-size: 1em;
  background-color: lightgreen;
  -webkit-appearance: none;
  border: 0;
  border-radius: .5em;
  padding: 1em;

.stats {
  display: flex;
  align-items: center

.stats > * {
  margin-right: 1em;

.info {
  font-size: 1.5em;


                // Browser support is only Chrome/Firefox so first let's check that.
if (window.ResizeObserver) {
  const log = document.getElementById('size')
  const body = document.querySelector('body')
  const observer = new ResizeObserver(entries => {
    // an array-like of ResizeObserverEntry
    for (const entry of entries) {
      log.innerHTML = entry.contentRect.height + 'px'
} else {
  document.getElementById('primary-content').innerHTML = 'Your browser does not support the <a href="">ResizeObserver</a>, come back using chrome or firefox.'

// ======================================
// The rest of this has nothign to do with
// the ResizeObserver

 * Simple function that fetches random bacon-ipsum
 * content and adds a paragraph making the area
 * larger.
async function addSomeMeat () {
  const p = document.createElement('p')
  p.setAttribute('contenteditable', 'true')
  const meats = await fetch('')
  p.innerHTML = (await meats.json())[0]

// Add some bacon event listener
document.getElementById('add').addEventListener('click', addSomeMeat)

// Reset event listener
document.getElementById('reset').addEventListener('click', () => {
  document.querySelectorAll('p:not(.intro)').forEach(p => p.remove())