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.


    <title>My To-Do List</title>
    <h1>My To-Do List</h1>
    <form id="form">
      <input type="text" id="input" placeholder="Enter something to do">
      <button type="submit">Add</button>
    <ul id="list"></ul>





                // Get a reference to the form and input elements
const form = document.querySelector("#form");
const input = document.querySelector("#input");
let todos = []; // create an empty array to store our todos
let listItems = []; // HTML list items for our list

const addItem = (item) => {    
    listItems += `<li class="task" id="${todos.length}">${item}</li>`;   

const updateList = () => {
  listItems = "";
  for(item of todos){    
    listItems += `<li class="task" id="${todos.length}">${item}</li>`;   
  // Add the new items to the list
  document.getElementById("list").innerHTML = listItems;

// Remove a task from the to-do list
const removeTask = (id, item) => {
  // create a new array
  const newList = [];
  // loop through the todos and only add tasks that weren't removed to the new array
  for(task of todos) {
    if(task != item){
  todos = newList; // assign the new list to the todos

const list = document.querySelector('ul');

// Listen for the clicks on the todo list
list.addEventListener("click", (event) => {  
// Listen for the form's submit event
form.addEventListener("submit", (event) => {
  // Prevent the default form submission behavior and keep the page from reloading

  // Get the value of the input field
  const item = input.value;

  // Create a new list item
  // Updates the list items
  // Add the new item to the list
  document.getElementById("list").innerHTML = listItems;

  // Clear the input field
  input.value = "";