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 class="todo-list">
 <div class="todo-header">Todo List</div>
 <todo-item text="Take dog out for a walk"></todo-item>
 <todo-item text="Get dog food on the way back"></todo-item>
 <todo-item text="Feed and cuddle with dog"></todo-item>


                .todo-list {
 padding: 10px;
 background: #6E7D8E;
 border-radius: 5px;
 box-shadow: 6px 9px 5px #b8b8b8;
.todo-header {
 color: #F3F3FC;
 padding: 10px 0px 5px 7px;
 font-size: 28px;


                class TodoItem extends HTMLElement {
 constructor() {
  // Always call super first

  // Create a shadow root
  const shadow = this.attachShadow({ mode: "open" });

  // Create div
  const div = document.createElement("div");
  div.setAttribute("class", "flex");

  // Write some CSS to apply to the shadow DOM
  const style = document.createElement("style");
  style.textContent = `
    .flex {
     display: flex;
     justify-content: space-between;
     background: #B9C0C0;
     border-radius: 4px;
     margin: 10px 8px;
    .text {
     padding: 9px 7px;
     color: dark;
    .btn {
     background: #808080;
     color: white;
     padding: 8px 10px;
     text-align: center;
     font-size: 13px;
     border: 3px solid #B9C0C0;
    .btn:hover {
     background: #333333;
     cursor: pointer;
   .btn:active {
     background: black;

  // Get todo text
  let text;
  if (this.hasAttribute("text")) {
   text = this.getAttribute("text");
  } else {
   text = null;
   console.error("Error: text attribute missing.");

  // Set div innerHTML
  div.innerHTML = `
   <div class="text">${text}</div>
   <div class="btn">&#10006;</div>
  // Attach the created elements to the shadow DOM

// Define the new element
customElements.define('todo-item', TodoItem);