To-Do List App with HTML, CSS & JavaScript

10 DAYS 10 PROJECT CHALLENGE

Day #03

Project Overview

The To-Do List App is a simple project perfect for a beginner who wants to learn how to create web pages and contribute to the open-source community. It is built with HTML, CSS, and JavaScript and allows users to add tasks to a list and keep track of the work they need to complete. The project uses a clean and simple interface, making it easy to view and manage different tasks.

This project will help you gain experience and confidence in your coding skills and prepare you for more complex assignments. You will see how JavaScript manipulates HTML elements and reacts to clicks and other user-initiated events. This is how you will learn to build interactive web pages and gain a thorough understanding of frontend development basics.

Key Features

  • Add Tasks: The user can add a task to a to-do list by simply typing it in an input fieldThis feature allows the user to maintain a running list of things he/she needs to accomplish.
  • Task Management: The app provides a simple interface where users can view and manage their added tasks in one place. This keeps the task list organized and easy to follow.
  • Edit Tasks: Users can edit an existing task whenever they want to correct or update its details. This makes the list more flexible and useful for managing changing tasks.
  • Delete Tasks: Users can remove tasks from the list when they are completed or no longer required. This helps keep the to-do list clean and organized.
  • Interactive Interface: The application responds to user actions through JavaScript. Tasks can be added, updated, or removed dynamically without refreshing the webpage.
  • Clean and Simple UI: The to-do list project has a clean, simple interface, making the task list itself the centerpiece of the appIt offers a distraction-free environment and keeps the user’s focus on managing the tasks.
  • Responsive Design: The To-Do List tasks manager is built with responsive design in mind, making it accessible and convenient to use on various devices.
  • Easy Customization: The simple HTML, CSS, and JavaScript structure makes the project easy to customize. Users can change the colors, fonts, spacing, buttons, and overall layout according to their preferences.

What You’ll Learn

  • Understand how to take user input from an HTML form.
  • Learn how to create and update HTML elements using JavaScript.
  • Learn how to add click events to buttons.
  • Practice adding and removing tasks dynamically.
  • Understand how to edit existing task information.
  • Learn how JavaScript can manage data displayed on a webpage.
  • Practice connecting HTML, CSS, and JavaScript to create an interactive project.
  • Understand the basics of building a task management application.
  • Practice creating a clean and responsive interface using CSS.

HTML Code

The HTML code below establishes the basic structure of the To-Do List App.The CSS file is linked inside the <head> section so that the webpage presentation can be separated from its structure. The tag contains the calculator’s primary elements, ensuring that the input section and the task list are appropriately organized.

The input field is used to enter a new task, while the button allows the user to add the task to the list. The task container is where the submitted tasks will appear. Finally, the JavaScript file is linked at the bottom of the <body> tag so that the script can access and interact with the HTML elements.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>To-Do List App</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="todo-container">
    <h1>To-Do List</h1>
    <div class="input-section">
      <input type="text" id="taskInput" placeholder="Enter a new task...">
      <button id="addTask">Add</button>
      <button id="clearAll">Clear All</button>

    </div>
    <ul id="taskList"></ul>
  </div>
  <script src="script.js"></script>
</body>
</html>

CSS Code

The CSS code controls the appearance and layout of the To-Do List App. It lays out the general appearance of the web page and the specific styles of the To-Do List App. For instance, the CSS code can be utilized to make the To-Do List responsive by applying Flexbox and other style conventions. It can also be used to design the task items and the buttons and set the borders and radii of the edges of the elements.

In addition, it can be used to set the margins, spacing, and colors of the To-Do List web application. The task items are given unique styles so that they are easily identifiable and organized. The responsive convention also helps make the To-Do List App more compact and easier to use on smaller screens.

body {
  font-family: Arial, sans-serif;
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  background: #002252;
}

.todo-container {
  background: #eea731;
  padding: 20px;
  border-radius: 12px;
  width: 400px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

h1 {
  text-align: center;
  margin-bottom: 20px;
}

.input-section {
  display: flex;
  gap: 10px;
}

#taskInput {
  flex: 1;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}

#addTask {
  padding: 10px 15px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}

#clearAll {
  width: 100%;
  padding: 10px 15px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}
#clearAll:hover {
  background: #a71d2a;
}


#addTask:hover {
  background: #0056b3;
}

ul {
  list-style: none;
  padding: 0;
  margin-top: 20px;
}

li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f1f1f1;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 8px;
}

li.completed {
  text-decoration: line-through;
  color: gray;
}

button.delete {
  background: #dc3545;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}

button.delete:hover {
  background: #a71d2a;
}

Javascript Code

The JavaScript code adds the interactive functionality to the To-Do List App. It uses the user input, the task, and constantly updates the task list. The code also implements event listeners to recognize clicking on buttons or tasks.

JavaScript can also handle actions such as editing and deleting tasks. When a task is added or removed, the displayed list is updated without requiring the webpage to reload. This demonstrates how JavaScript can manipulate HTML elements and create an interactive task management application.

const taskInput = document.getElementById("taskInput");
const addTaskBtn = document.getElementById("addTask");
const taskList = document.getElementById("taskList");
const clearAllBtn = document.getElementById("clearAll");


let tasks = JSON.parse(localStorage.getItem("tasks")) || [];

// Render tasks
function renderTasks() {
  taskList.innerHTML = "";
  tasks.forEach((task, index) => {
    const li = document.createElement("li");
    li.className = task.completed ? "completed" : "";

    li.innerHTML = `
      <span>${task.text}</span>
      <div>
        <button onclick="toggleTask(${index})">✔</button>
        <button class="delete" onclick="deleteTask(${index})">✖</button>
      </div>
    `;

    taskList.appendChild(li);
  });
}

// Add task
addTaskBtn.addEventListener("click", () => {
  const text = taskInput.value.trim();
  if (text !== "") {
    tasks.push({ text, completed: false });
    localStorage.setItem("tasks", JSON.stringify(tasks));
    renderTasks();
    taskInput.value = "";
  }
});

// Toggle complete
function toggleTask(index) {
  tasks[index].completed = !tasks[index].completed;
  localStorage.setItem("tasks", JSON.stringify(tasks));
  renderTasks();
}

// Delete task
function deleteTask(index) {
  tasks.splice(index, 1);
  localStorage.setItem("tasks", JSON.stringify(tasks));
  renderTasks();
}
// Clear all task
clearAllBtn.addEventListener("click", () => {
  tasks = [];
  localStorage.removeItem("tasks");
  renderTasks();
});


// Initial render
renderTasks();

Your Task

Create a similar project on your own and share your CodePen link in the comments.
I’ll review your work and share my feedback as a reply!

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Related Projects

Day 5 : Quiz App

A multiple-choice quiz with score tracking.

Concepts: Loops, conditionals.

Day 6 : Random Quote Generator

Displays a random quote on button click or from an API.

Concepts: Math.random(), API fetch.

Day 7 : Countdown Timer

A countdown timer for events (e.g., New Year countdown).

Concepts: Date object, time calculations.