css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!doctype html>
<html lang="en-US">
    <meta charset="utf-8">
    <!-- Ensures proper rendering and touch zooming -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Forces IE 8/9/10 to use its latest rendering engine -->
    <meta http-equiv="x-ua-compatible" content="ie=edge">
  	<title>To-Do List</title>
    <link rel="icon" href="../img/favicon.ico">
    <link rel="icon" href="../img/favicon-32.png" sizes="32x32">
    <link rel="stylesheet" href="styles.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <script src="script.js"></script>
    <div class="container">
  		<h2>To Do</h2>
  		<form name="listForm">
        <!-- These elements must be on the same line for styling. Button class of button is used in JavaScript -->
  			<input type="text" name="listItem" placeholder="Add new"><button type="button" class="button">+</button>
      <!-- Class 'sortable' enables sorting with jQuery UI method sortable() -->
  		<ul class="sortable">
        <li>Work on projects for one hour</li>
        <li>Go for a walk</li>

              body {
  text-align: center;
  font-family: Helvetica;
  font-size: 14px;
  color: #666;
  background: linear-gradient(to left, #da4453, #89216b);
  height: 100%;
  /* Ensures background image spans full width of viewport */
  margin: 0;
  padding: 0;

.container {
  padding: 5px 15px 10px 15px;
  width: 400px;
  /* 0 is for top and bottom and auto (set to equal values for each by browser) for left-right */
  margin: 0 auto;
  margin-top: 40px;
  background: #eee;
  border-radius: 5px;

form {
  /* Displays button next to input box */
  display: inline-block;
  margin-bottom: 1.5em;

input {
  border: 1px solid #ccc;
  height: 1.6em;
  width: 28.23em;
  color: #666;
  /* Adds space between text and input box outlines */
  padding-left: 0.5em;

/* Sets appearance of input box boundaries when user clicks inside it */
input:focus {
  border-color: #da4453;
  /* L to R: horizontal offset, vertical offset, blur radius. A in RGBA is alpha parameter, a number between 0.0 (fully transparent) and 1.0 (fully opaque) */
  box-shadow: 0 0 8px rgba(229, 103, 23, 0.6);
  outline: none;

button:focus {
  outline: none;

button {
  margin-left: -26px;
  /* 2px added to account for default 1px padding of input box set by user agent (browser) stylesheet (1px top + 1px bottom = 2px) */
  height: -webkit-calc(1.6em + 2px);
  height: calc(1.6em + 1.2px);
  width: 25px;
  color: grey;
  border: none;

.button:hover {
  cursor: pointer;
  opacity: 0.8;
  color: #9a9797;

/* Remove margins and padding from list */
ul {
  margin: 0;
  padding: 0;

/* Applies styling to any li descendants of ul (descendant combinator) */
ul li {
  text-align: left;
  /* Prevents default bullet points */
  list-style-type: none;
  line-height: 1.5em;
  cursor: pointer;
  background-color: #eee;
  /* First value sets top and bottom padding; second value sets right and left */
  padding: 1.5px 0;

/* Set all odd list items to a different color (zebra stripes) */
ul li:nth-child(odd) {
  background: #f9f9f9;

/* Sets darker background color on hover over list items */
ul li:hover {
  background-color: #ddd;

.strike {
  text-decoration: line-through;

/* Mobile phones/extra small screens */
@media screen and (max-width: 767px) {
  .container {
    padding: 0 0 5px 0;
    width: 90%;
    /* Removing this adds space above container div */
    margin: 1.5em auto;

  form {
    display: block;
    margin-bottom: 13px;

  h2 {
    margin-top: 0;
    padding-top: 10px;

  input {
    width: 90%;
    margin: 0;

  ul {
    margin-right: 10px;
    margin-left: 10px;

              $(function() {

  $('.button').click(function() {
    let toAdd = $('input[name="listItem"]').val();
    // If nothing in input box, ceases function execution
    if (toAdd === '') return;
    // Inserts li as first child of ul
    $('ul').prepend('<li>' + toAdd + '</li>');
    // Clears input box after clicking '+'

  // Upon hitting enter, triggers button click and prevents page from refreshing
  $('input[name="listItem"]').keypress(function(e) {
    if (e.which == 13) {

  $('ul').on('click', 'li', function() {
    // Upon list item click, toggleClass() adds class 'strike' for it and fadeOut() completely hides it

  // Enables drag reordering of list items (uses linked jQuery UI library)


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................