Build a To-Do App using HTML, CSS & JavaScript ⚡

⚡ Build a To-Do App using HTML, CSS & JavaScript

Hello everyone πŸ‘‹
Welcome back!

In this beginner-friendly project, we will create a simple To-Do App using HTML, CSS, and JavaScript πŸ’»

This project helps you learn:

- DOM Manipulation
- Event Handling
- LocalStorage
- JavaScript Logic

Perfect for beginners πŸš€

---

🌟 Features of To-Do App

✔ Add new tasks
✔ Mark tasks as completed
✔ Delete tasks
✔ Clean responsive design
✔ Data stored using LocalStorage

---

🧱 Step 1: HTML Code

<!DOCTYPE html>
<html>
<head>
    <title>To-Do App</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<div class="todo-container">
    <h1>My To-Do List</h1>

    <div class="input-section">
        <input type="text" id="taskInput" placeholder="Enter your task...">
        <button id="addBtn">Add</button>
    </div>

    <ul id="taskList"></ul>
</div>

<script src="script.js"></script>
</body>
</html>

---

🎨 Step 2: CSS Code

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

.todo-container {
    background: white;
    padding: 25px;
    width: 400px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

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

input {
    flex: 1;
    padding: 10px;
}

button {
    padding: 10px 15px;
    background: green;
    color: white;
    border: none;
    cursor: pointer;
}

li {
    margin-top: 10px;
}

---

⚡ Step 3: JavaScript Code

let taskInput = document.getElementById("taskInput");
let addBtn = document.getElementById("addBtn");
let taskList = document.getElementById("taskList");

addBtn.addEventListener("click", addTask);

function addTask() {
    let task = taskInput.value;

    if(task === "") {
        alert("Please enter a task");
        return;
    }

    let li = document.createElement("li");
    li.textContent = task;

    li.addEventListener("click", function() {
        li.style.textDecoration = "line-through";
    });

    let deleteBtn = document.createElement("button");
    deleteBtn.textContent = "Delete";

    deleteBtn.addEventListener("click", function() {
        li.remove();
    });

    li.appendChild(deleteBtn);
    taskList.appendChild(li);

    taskInput.value = "";
}

---

🎯 What You Will Learn

✅ DOM Manipulation
✅ JavaScript Events
✅ Dynamic Task Creation
✅ Beginner Project Logic

---

⭐ Tips

- Try changing colors 🎨
- Add dark mode πŸŒ™
- Store tasks in LocalStorage πŸ’Ύ

---

πŸ“Œ Conclusion

This was a simple To-Do App project using JavaScript.
A perfect beginner project to improve your coding skills πŸš€

---

πŸ“’ Also Read

- JavaScript Interview Guide
- Calculator Project
- Python Programs

---

πŸ‘‰ Save and share this post πŸ“Œ
πŸ‘‰ Follow for more coding projects πŸ’»

Comments

Popular posts from this blog

Build a Simple Calculator using HTML, CSS & JavaScript (Beginner Project)

Top 10 Python Programs for Beginners (Easy + Practical Guide)

JavaScript Notes for Beginners (Simple + Easy Guide) ⚡