Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <html>
  <head>
    <title>Site Title</title>
  </head>
  <body>
    <h2>Actions</h2>
    <div class="actions">
      
      <button onclick="modify()">Modify second list item</button>
    <button onclick="insertEnd()">Insert fourth list item</button>
    <button onclick="insertBetween()">Insert paragraph element between the existing ones</button>
    </div>
    <hr>
    <div class="main-body">
      <h1>Article Heading</h1>
      <p>The second list item will change 5 seconds after the page loads.  Refresh the page to see it again if you missed it.</p>
      <p>Some more text</p>
      <ul>
        <li>List item 1</li>
        <li>List item 2</li>
        <li>List item 3</li>
      </ul>
    </div>
    <div class="footer">
      <p>Site created by Zach</p>
    </div>
  </body>
</html>
              
            
!

CSS

              
                .actions {
  display: flex;
}

.actions button {
  margin: 3px;
}

.actions button:hover {
  cursor: pointer;
}
              
            
!

JS

              
                function modify() {
  const list = document.querySelector('ul');
  // Remember, arrays are "zero-indexed"
  const secondListItem = list.children.item(1);
  secondListItem.textContent = 'a new value';
}

function insertEnd() {
  const list = document.querySelector('ul');
  const newItem = document.createElement('li');
  newItem.textContent = 'new item';
  list.appendChild(newItem);
}

function insertBetween() {
  // Step 1: Find the element we want to insert something after
  const mainBody = document.querySelector('.main-body');
  const pItems = mainBody.querySelectorAll('p');
  const secondParagraphElem = pItems.item(1);

  // Step 2: Create the element we want to insert
  const newElem = document.createElement('p');
  newElem.textContent = 'some inserted text';

  // Step 3: Insert the element
  mainBody.insertBefore(newElem, secondParagraphElem);
}

              
            
!
999px

Console