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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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.


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.


                <link href="" rel="stylesheet" />
<script src="" async></script>

<!-- Need to add a small wrapper with any important setup -->
<div data-preview="true" data-theme-id="light" data-prefill='{"title":"","tags":[],"scripts":[],"stylesheets":[]}'>

  <pre><code class="language-html" data-lang="html">&lt;h1&gt;Hello World&lt;/h1&gt;</code></pre>

  <pre><code class="language-css" data-lang="css">html {
  background: hsl(290, 50%, 10%);
  color: white;
  font-family: monospace;

  <!-- You can also have hidden support code! -->
  <pre hidden><code data-lang="js">console.log('hello world');</code></pre>



                html {
  // background: hsl(290, 50%, 10%);
  // color: white;
  padding: 1em;

.prefill-click-to-run {
  border-radius: 2em;
  appearance: none;
  background: none;
  padding: 0.25em 1em;
  border: solid 1px;
  font: inherit;
  color: inherit;
  margin: 1em auto;
  display: inline-block;
  position: relative;
  left: 50%;
  transform: translateX(-50%);

[data-make-prefill] {
  opacity: 0;



                /* Inject the CodePen script once when needed. */
const injectCodePenEmbedScript = (function () {
  let scriptLoaded;
  return function (callback) {
    if (scriptLoaded) {
      callback && callback();
    let script = document.createElement("script");
    script.onload = function () {
      scriptLoaded = true;
      callback && callback();
    script.src = "";

/* ---------------------------------- */

function replaceWithPrefillEmbed(el) {
  /* We can't directly pass an element into the __CPEmbed() function yet, it has to be a selector. Instead, we add a temporary attribute to target. */
  el.setAttribute("data-make-prefill", true);
  injectCodePenEmbedScript(() => {
    /* This is part of our embed scripts UI to turn elements matching a selector into embeds after the script has already run */

/* ---------------------------------- */

/* Clone the whole example to leave the original code snippets visible above the embed */
function appendPrefillEmbed(el, button) {
  let clone = el.cloneNode(true);

/* ---------------------------------- */

/* Add a button to each .example element to activate the Prefill Embed */
  (el) => {
    const button = document.createElement("button");
    button.innerHTML = "Click to Run";
    button.setAttribute("class", "prefill-click-to-run");

    button.addEventListener("click", () => {

      /* OR */